Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

I want to truncate numbers converted to integers.

How do I do this?
0 Kudos
Message 1 of 5
(4,542 Views)
Depends on what you want to do. Which part of the number are you truncating (can you give an example?). What programming language are you using?
0 Kudos
Message 2 of 5
(4,542 Views)
I'm using LabVIEW. I want to truncate the fractional part of a number. For example 9.71258 would become 9 when converted to an integer.
0 Kudos
Message 3 of 5
(4,542 Views)
LabVIEW has a set of conversion vi's under Functions->Numeric->Conversions that will take floats and covert them to integers. This will truncate the fractional part. In addition, LabVIEW can automatically cast numbers to the appropriate type - when you connect a float number to a vi that takes a U8 input for example.

If you don't want to do a conversion, you can use the "round to nearest", "round to +infinity" (ceiling), and "round to -infinity" (floor) functions which will truncate/round floats.
0 Kudos
Message 4 of 5
(4,542 Views)
Thanks. You've been very helpful. The "round to - infinity seems to work. I had tried the conversions and they seem to round the number rather than truncate. I'll use the "round to - infinity".
0 Kudos
Message 5 of 5
(4,542 Views)