LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

coerce 32bit real number to interger with one decimal

I couldn't find any function to convert/coerce number with more than 2 decimal points to a number with single decimal point. Is there any?

0 Kudos
Message 1 of 6
(3,066 Views)
I have to admit confusion as to what you're asking for. Your title asks about coercing a 32-bit real to an integer with one decimal. Integers don't have decimals. The body of your message ask how to convert/coerce a number with more than 2 decimal points to a number with a single decimal point. What's a number with 2 decimal points? Is that some new math?
0 Kudos
Message 2 of 6
(3,064 Views)

Sorry for the confusion...I admit it shouldn't be 'integer'.

This is what I want.

If the input is 14.98 the output should be 15.0 but if input is 14.94 the output should be 14.90

I hope this makes it clear....

0 Kudos
Message 3 of 6
(3,057 Views)

Hi ABM26,

 

the usual way is to multiply by 10, round to nearest, divide by 10. :smiley-wink:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 6
(3,052 Views)

Oh, you're looking for the number of decimal places. OK. Is this just for display purposes? If so, you can just set the Format & Precision for the numeric control to %.1f as follows:

  1. Right-click on control and select Format & Precision.
  2. Select "Floating point" from the listbox.
  3. Set "Digits" to 1.
  4. Set "Precision Type" to "Digits of precision".
If you actually want to convert it then you just need to precisely what Gerd said. Smiley Wink
0 Kudos
Message 5 of 6
(3,049 Views)

Thanks...

0 Kudos
Message 6 of 6
(3,047 Views)