LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to round down rather than automatic round up at .5

Solved!
Go to solution

I really have lost my brain cells to work out suitable formula to achieve this!

I need at all cost be able to round down on the result of an equation. Obviously Labview compliant with IEEE would always round up at/above .5. Is there a way to achieve what I am after?

Many thanks

K Waris

ATE and Labview Consultant
https://www.easybodge.com
0 Kudos
Message 1 of 7
(3,836 Views)
Solution
Accepted by topic author k-waris

Does Round Toward -Infinity do the job?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 7
(3,829 Views)
Define .5. What about .4999999999999.

Up or down?

There is no such thing as exactly .5.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 7
(3,795 Views)

mikeporter wrote:
There is no such thing as exactly .5.


Sorry, but that's not correct.  Dividing any integer by 2 gives a floating representation of that integer times 2^(-1)..  To see the "exact" representation of, say, 9/2, typecast it to an array of U8 (bytes), and you'll see 64 18 0 0, exponent and mantissa.

 

BS

 

 

 

0 Kudos
Message 4 of 7
(3,748 Views)

@k-waris wrote:

I really have lost my brain cells to work out suitable formula to achieve this!

I need at all cost be able to round down on the result of an equation. Obviously Labview compliant with IEEE would always round up at/above .5. Is there a way to achieve what I am after?

Many thanks

K Waris


Actually, the statement in bold is untrue.  IEEE standard for "round to nearest" is "round to even integer", which is the rule that LabVIEW follows.

 

http://zone.ni.com/reference/en-XX/help/371361H-01/glang/round_to_nearest/

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 7
(3,683 Views)

That solved my problem. Thank you

ATE and Labview Consultant
https://www.easybodge.com
0 Kudos
Message 6 of 7
(3,677 Views)

Note that this method might not work like you want for negative numbers. If you want -3.2 to round to -3, you will need to check the sign and if negative round to +inf.


___________________
Try to take over the world!
0 Kudos
Message 7 of 7
(3,660 Views)