LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert Double to String without zeros at the end

Hello,
how can i convert a double-numeric to a string? I know how can do it but not how i can do it in a fast way.
When i use the "Number to Fractional String"-Object then a number
1,2 --> is canged to 1,200000
1,0 --> changed to 1,000000

what can i do that there are no zeros at the end?

Currently i´m reading the reversed string in a loop to remove the zeros, but this i to slow i think.
Is there a fast way?

Thanks for your help
0 Kudos
Message 1 of 9
(15,041 Views)

You can change the precision for the number in the "number to fractional string" function.

 

Tom

Message Edited by Tom Haggerty on 05-14-2007 08:49 AM

 

 

Message Edited by Tom Haggerty on 05-14-2007 08:50 AM

Message 2 of 9
(15,035 Views)
Hi OnlyOne,

use the function 'Format into String' with a format code of '%#f'!

And read the context help for this function (and the linked pages for the format string syntax)!
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 9
(15,030 Views)
I hope I understood you righ...

Edit: GerdW was faster 😉

Message Edited by ceties on 05-14-2007 07:55 AM

LV 2011, Win7
Message 4 of 9
(15,029 Views)
Do you know that the number of digits after the decimal point can be set by the Precision input of Number to Fractional String ? This would be the easiest way to format your string if the number of digits after the decimal point is always the same.

Should the number of digits be variable, then use Format Value with the format input set to %#f !

Message Edité par JB le 05-14-2007 02:59 PM

Message 5 of 9
(15,024 Views)
Hello,
thanks for all the answers. Works great with the "Format Into String".
Is there also Format-syntax that the produced string shows a "." instead of a "," ?
1,3234 -> 1.3234 instead of 1,3234

Thx
0 Kudos
Message 6 of 9
(15,024 Views)
Hi OnlyOne,

please read the context help, there's a huge page on those syntax elements:
Format string should be: %.;%#f

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(15,016 Views)
Extract from the LV help :


Select
Tools»Options to display the Options dialog box and select Front Panel from the Category list to display this page.

Use this page to set front panel options.

This page includes the following components:

  • Open the control editor with double click—Allows you to double-click a control to display the Control Editor window. Use the Control Editor window to customize the appearance of a front panel object. This checkbox is unchecked by default.
  • Use localized decimal point—Uses the decimal separator for the operating system instead of the period. This checkbox is checked by default. Remove the checkmark from this checkbox if you want LabVIEW to use periods in all cases for the decimal point.
  • ...

Message 8 of 9
(15,016 Views)
Hello JB,
thanks for the help.
I know this option to set it. But when i give the software to someone else it must be 100% that it creates a "." and not a comma ",".
So i will use the "%.;%#f"-command.

Thx
0 Kudos
Message 9 of 9
(14,998 Views)