1. ## Number rounding command?

I'm at a total loss on this one. I'm trying to find a command that will round a number, but I can't find it anywhere in RRExt or base RR skin commands.....

Here's the situation. I'm using RRFusion to read some sensors in my car, one being the Throttle Position sensor. I'm converting the RAW (0-1023) data to a voltage using .00488, which is the published voltage step for the fusion brain hardware, then taking that voltage, and turning it into a percentage. The closed throttle voltage is .625v and wide open throttle is 3.850v. So to convert the sensor voltage to a %, I'm taking the voltage, minus the minimum (.625), divided by the range (3.225), times 100 (to give the whole number percentage). The problem lies in the math though. With each calculation, there's more and more decimal places added on, and I need to remove all of them so in the end, i just have 0-100. This is why I need something that will round to the nearest whole number.

Does anyone know if such a command exists, and if it doesn't, could you please add it anthony? lol

Thanks everyone...Matt

2. Not sure how you would do it in skin commands but I see that the MOD(%) function is supported so you could try something like:

x=x - (x % 1)

If there were also a DIV function, you could use

x=x DIV 1

Hmm, not sure if AND(&) would work on a floating point number... Maybe:

x=x & 127

3. For the time being, i have a series of BYRANGE statements used to manually round the number one way or another, starting at 0, ending at .4999 for each percent rise

so for instance...

"TPSB0","BYRANGE;\$TPSB\$;0;.4999;SETVAR;TPS;0<<TPSB 1"
"TPSB1","BYRANGE;\$TPSB\$;.5;1.4999;SETVAR;TPS;1<<TP SB2"

and so on up to 99.5;120 (just in case the voltage goes just slightly past the 100% mark)

lots of code to do such a simple thing...

4. You can say that again, i'm glad you only posted a snippet of that chunk of code

#### Posting Permissions

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