LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a simple way to limit the digits after a decimal point for a number

I am storing a "DBL" number as a string, as I have lot of numbers, the string is getting bigger, I need only 3 digit precision. Is there a simple way to cut the extra digits from the number before converting it to a string?

Thanks,

Mudda
0 Kudos
Message 1 of 5
(5,513 Views)
Hello Mudda,

I assume that you are using Number to Fractional String to convert the numbers to strings. If so, there is an input of that function called precision that you can use for that.
If you are using Format Into String, you can configure this by double clicking on the icon of the function.

Hope this helps,
Paulo
0 Kudos
Message 2 of 5
(5,510 Views)
Paulo,
Sorry I didnot include all the information in my last message. Here what I am doing, I have a big cluster in that cluster I have 4 arrays of numbers "DBL", and also some strings. I am flattening this whole cluster into a string and saving to a file. So, My file is getting bigger as there are 5 to 6 digits after the decimal in each number, I want to limit 2 digits after decimal for each number so that my file size is reduced. I can convert the numeric array into strings then flatten it to a file, but I was looking for some thing easy to just take out some digits from the number.

Thanks,
Mudda.
0 Kudos
Message 3 of 5
(5,507 Views)
If you flatten a DBL number to a string, it will retain exactly the same number of bits as the binary representation, the displayed precision is irrelevant (8 bytes for DBL). The number of decimal digits only matters in you format into string.

Mybe you can use a different representation, e.g. I32 or SGL?
0 Kudos
Message 4 of 5
(5,492 Views)
Looks like you will have to break out each array and used 'Number to Fractional String' to convert the numeric arrays into string arrays with 2 decimal points and the put them arrays back into the cluster. Fortunately this function will take an array as an input.
Randall Pursley
0 Kudos
Message 5 of 5
(5,476 Views)