# Thread: Integer or Round function with RR

1. ## Integer or Round function with RR

I create a value (DFXSPEEDINPERCENT) with an other but i should like to obtain the Round or the Integer of this value.
Code:
`EVAL;DFXSPEEDINPERCENT;\$DFXSPEED\$/65535*20`
How can i do that with RR .

Thanks

2. I think it will you use RREXTENDED PI and the function RNDVAR
"RndVar;<VALUE TO ROUND>;<NUMBER OF PLACES>;<RESULT VAR>"
* \$MYVAR\$ = 15.458468413874
Example: "RndVar;\$MYVAR\$;0;RESULT"
Result: RESULT = 15

3. use \ for integer division: EVAL;DFXSPEEDINPERCENT;\$DFXSPEED\$/65535*20

4. Originally Posted by guino
use \ for integer division: EVAL;DFXSPEEDINPERCENT;\$DFXSPEED\$/65535*20
Like that ?
EVAL;DFXSPEEDINPERCENT;\$DFXSPEED\$\65535*20

My label is that:
Code:
`L,20,218,300,34,169,197,209,22,"Arial:BI","=\$DFXSPEEDINPERCENT\$||=%","LEFT",,"DS=2,2,0,0,0"`

5. I'm not too sure on that one, I THINK it should be / I have never seen a forward slash used for division..... Even in the example he is using the /, which looks correct.

6. In fact,
EVAL;DFXSPEEDINPERCENT;\$DFXSPEED\$\65535*20 don't run

So where i use the \ please ?

7. \ is integer division, / is float point division, so you did in fact replace it as I meant you to do (sorry for not replacing it myself on the example), the issue you're probably getting however is the math involved with integer division (if you get any number less than 65535 and do an integer division by 65335 you get ZERO), so try THIS:

EVAL;DFXSPEEDINPERCENT;(\$DFXSPEED\$*20)\65535

Alternatively, this should be equivalent to rounding a number:

EVAL;RESULT;MYFLOATVAR\1

If MYFLOATVAR = 1.23 then RESULT=1
If MYFLOATVAR = 1.57 then RESULT=2 (it will get rounded - there are ways to make it not round it off)

If you use this method you can do all your calculations as usual, then at the end just get the result and round it off.

8. Wonderfull Guino,
I confirm that :
EVAL;DFXSPEEDINPERCENT;(\$DFXSPEED\$*20)\65535
give me well an integer result :-)
I suppose that if i want a result updated each second i must to use a timer ?

9. Unfortunately, yes... I think it's time we add an "EVAL" label code so that you can place complex stuff into labels directly.. we'll have to add a way to allow label codes directly in the expressions though..

10. Cool,
may be for the november release ?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•