1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2013
Posts
42
Rep Power
2

#### Abs function

Hi there.. I am trying to add this row, the abs function works, but I need to cut the decimals down to none..

how do I do this?

Code:
`abs(float(row['DEAL_MARGIN']) / float(row['COUNTER_AMT']) * 10000))`
complete code for adding the row:
Code:
`t.addData((row_nr,11),abs(float(row['DEAL_MARGIN']) / float(row['COUNTER_AMT']) * 10000))`
2. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Location
/dev/null
Posts
164
Rep Power
19
You may try the int function (though it is intended for a different purpose)

Code:
```>>> int(abs(-2.345))
2```
3. Code:
```>>> help(round)
Help on built-in function round in module __builtin__:

round(...)
round(number[, ndigits]) -> floating point number

Round a number to a given precision in decimal digits (default 0 digits).
This always returns a floating point number.  Precision may be negative.```

• ChristopherL agrees : Thank you :)
4. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2013
Posts
42
Rep Power
2
Originally Posted by b49P23TIvg
Code:
```>>> help(round)
Help on built-in function round in module __builtin__:

round(...)
round(number[, ndigits]) -> floating point number

Round a number to a given precision in decimal digits (default 0 digits).
This always returns a floating point number.  Precision may be negative.```
Had some trouble with it so thought it was something, just needed to sort out my paranthesis

Solved with

Code:
`t.addData((row_nr,11),round(abs(float(row['DEAL_MARGIN']) / float(row['COUNTER_AMT']) * 10000),0))`
5. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Location
/dev/null
Posts
164
Rep Power
19
Originally Posted by ChristopherL
I need to cut the decimals down to none
Remember that round does more than just cutting down the decimals
Code:
```>>> round(2.35)
2
>>> round(2.53)
3```