LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to extract till the first value after the decimal in a dbl

Hi Guys

 

I want to take a number upto its first significant  value after the decimal point.

 

For example. If I got a number as 11.1234. But I want this number as 11.1.

How can I convert this number in labVIEW?

 

0 Kudos
Message 1 of 4
(2,930 Views)

Hi trip,

 

did you try a format string of "%.1f"?

 

Or you may round after reading in your number: y := RoundToNearest(x*10)/10…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 4
(2,919 Views)

Multiple Possible Methods

 

Method 1.As suggested by Gerd (Format into string) and then Converting the string value to Numeric Value

Method 2.Convert Number to fractional String with precision1 and then convert back Fractional string  to Number

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 4
(2,900 Views)
Method 3: multiply number by 10, convert to integer, then divide by 10. (This truncates unwanted precision)

Method 4: same as Method 3, but use Round to Nearest in the middle. (Gives a rounded result)

Can you say a bit more about the whole problem? Do you have just a single number that you want to convert or is this value part of a data stream, list or array, where you have some number of sequential values you need to process?

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 4 of 4
(2,882 Views)