Announcement

Collapse
No announcement yet.

Integer or Round function with RR

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

    Comment


    • #3
      use \ for integer division: EVAL;DFXSPEEDINPERCENT;$DFXSPEED$/65535*20
      Ride Runner RR's Myspace

      "Being happy is not about having what you want, it's about wanting what you have."
      "The best things in life are always free - but that doesn't mean money can't buy you good things."

      Comment


      • #4
        Originally posted by guino View Post
        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"
        Last edited by pierrotm777; 10-06-2011, 04:12 AM.

        Comment


        • #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.
          Front End of Choice: Ride Runner (Is there anything else??? ) & Powered by the DFX5.1 Skin Available in the Mobile App Mart

          My Fiero Build Thread

          Comment


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

            So where i use the \ please ?

            Comment


            • #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.
              Last edited by guino; 10-06-2011, 02:22 PM.
              Ride Runner RR's Myspace

              "Being happy is not about having what you want, it's about wanting what you have."
              "The best things in life are always free - but that doesn't mean money can't buy you good things."

              Comment


              • #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 ?

                Comment


                • #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..
                  Ride Runner RR's Myspace

                  "Being happy is not about having what you want, it's about wanting what you have."
                  "The best things in life are always free - but that doesn't mean money can't buy you good things."

                  Comment


                  • #10
                    Cool,
                    may be for the november release ?

                    Comment

                    Working...
                    X