Results 1 to 4 of 4

Thread: Number rounding command?

  1. #1
    Variable Bitrate
    Join Date
    Sep 2007
    Location
    Export, PA
    Posts
    265

    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
    Planning: [|||||||||-] 90%
    Purchased: [|||||||||/] 99%
    Installation: [|||||||||-] 90% (when is anyone's project ever REALLY done...)

  2. #2
    Constant Bitrate
    Join Date
    May 2008
    Posts
    223
    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. #3
    Variable Bitrate
    Join Date
    Sep 2007
    Location
    Export, PA
    Posts
    265
    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...
    Planning: [|||||||||-] 90%
    Purchased: [|||||||||/] 99%
    Installation: [|||||||||-] 90% (when is anyone's project ever REALLY done...)

  4. #4
    The Curator
    Auto Apps:loading...
    Blue ZX3's Avatar
    Join Date
    Aug 2004
    Location
    Chicago area,IL
    Posts
    5,079
    You can say that again, i'm glad you only posted a snippet of that chunk of code
    RideRunner...The #1 FE, PERIOD.

    Current Project: DFXVoice [v1.0 Released]
    Next in line: RRMedia v2.0

    DFX 5.1.1 Skin
    Appstore Link

    My RideRunner Plugins
    RRMedia
    RRExtended
    DFXVoice

    "There are no bugs - only undocumented features."

Similar Threads

  1. .net Bluetooth Mobilephone Plugin
    By lambosprit in forum RR Released Plugins
    Replies: 1337
    Last Post: 06-08-2014, 08:34 PM
  2. Replies: 0
    Last Post: 02-11-2010, 11:58 AM
  3. Use temperature sensor to trigger RR command
    By deus ex machina in forum Road Runner
    Replies: 7
    Last Post: 10-23-2008, 05:38 AM
  4. TIMER command
    By Enforcer in forum Road Runner
    Replies: 4
    Last Post: 10-22-2006, 08:14 AM
  5. format settings of "tempx" command ???
    By tolisn in forum Road Runner
    Replies: 2
    Last Post: 11-28-2005, 12:01 PM

Bookmarks

Posting Permissions

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