LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fractional sting to decimal number conversion

Hi!
I want to convert my fractional string to number in the following format. I want to restrict number after 3 decimal. Can anybody help.

My fractional string - 123.456789 i want number - 123.456
- 12.123456 - 12.123
- 123456.123456 - 123456.123

Kaustubh
VC (Pune)
INDIA
0 Kudos
Message 1 of 6
(2,540 Views)
Hello Kaustubh,

just convert string to number using "Scan from String" and then round your number (multiply by 1000, round to nearest, divide by 1000).
Perhaps the formatting of the output indicator may help: just show the number with only 3 decimals after the point.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,533 Views)
You can scan from string to a float and then convert it back to a string using %.3f this will return a string with 3 digits of percision after the decimal point independent of howmany it started with or you can parse the string and shorten it (remember that \. is needed to recognize the decimal in a regular expression).

Paul
Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 6
(2,513 Views)
Check this out 🙂

The attached VI allows # of decimal point control

Cheers!
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
Message 4 of 6
(2,502 Views)
Thanks Ian F K
It works.
Thank You

Kaustubh
VC (Pune)
INDIA
0 Kudos
Message 5 of 6
(2,497 Views)
You're most welcome 🙂

Alternatively, you may also thank us by rating our replies, as it let us know to what extend that our replies help 🙂

Cheers!
Ian F
Since LabVIEW 5.1... 7.1.1... 2009, 2010, 2014
依恩与LabVIEW
LVVILIB.blogspot.com
Message 6 of 6
(2,493 Views)