Convert real to int

  • I know I can put the value of a real variable into an int variable, and that an implicit conversion is then done.
    But then you get a warning in Workvisual that precision might be lost.
    Is there way to do explicit conversion, so you don't get the warning in Workvisual (orange colour underlined)?

  • 1. Please read READ FIRST
    2. What WoV Version?
    3. What Editor or plugin name? WoV has tons of editors... How are we supposed to know what you have in mind?
    4. How about screenshot?



    I am guessing that this is in a program editor and not in one of the configuration editors... but why bother guessing

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Well, precision is always lost when converting from Real to Integer -- you're going from N decimal places to 0 decimal places.


    Assuming that you are doing a simple assignment like IntegerVariable = RealVariable, the key factor to keep in mind is that the con version is a simple truncation. So if RealVariable is 5.0, 5.4, 5.6, or 5.9, IntegerVariable will always be 5.

  • some people are only good at wasting other peoples time...
    don't know how to as question, don't bother answering questions aimed to HELP THEM... :stupid:



    imho, that is worth a ban (no different that spam)

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • I am working in Workvisual 4.0.29.
    I am programming some code in the 'Configuration and commissioning' workspace, in the sps.sub.
    In the attachment you see that the compiler generates a warning at the line $RED_VEL = OvrSpd,
    because a real value is assigned to an int variable.
    This is normal since an 'implicit' conversion is done, and precision can be lost.
    I just want to avoid the warning to appear. So I thought maybe there could some instruction that tells the compiler 'explicitly'
    to convert the real value to an int value, so generation of a warning would not be necessary anymore

Advertising from our partners