LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display format question

Solved!
Go to solution

Hi

I am having trouble to understand something which appears simple.

In one of my controls I am using, I select in the Display Format this :

nitad54449_0-1729758706502.png

So, I would expect that 0.001 appears as 1E-3. To my surprise, for these values 

nitad54449_1-1729759190411.png

 

I get these results.

nitad54449_2-1729759216149.png

 

Is it me or there is a problem ?

Win 11, LV Pro, 2023 Q1 (64-bit) 23.1f276

I attach the vi here in 2023 and 2019 if someone can confirm.

Thanks for help

 

thanks for any help

Download All
0 Kudos
Message 1 of 18
(603 Views)

0.001 written with 2 decimal places is 0. You probably want 2 significant digits mode.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 18
(594 Views)

Hi Nitad,

 


@nitad54449 wrote:

Is it me …?


Yes.

 

  • You configure "automatic formatting", so LabVIEW decides on its own to display either "0.001" or "1E-3".
  • You configure to hide trailing zeros, so LabVIEW will not display "0.00", but "0" instead.
  • You configure to display only 2 "digits of precision" instead of "significant digits".

This will result in "0.0" (2 digits of precision), which will be shortened to "0" (no trailing zeros).

Once LabVIEW decides to use scientific format (due to "automatic formatting") you get "1E-5"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 18
(593 Views)

I don't get it: why 1E-3 and 1E-4 are shown as 0 and 1E-5 is shown as 1E-5 ?  I would expect that any number smaller than 0.01 to be either shown as 0 or switched automatically to scientific notation.

0 Kudos
Message 4 of 18
(561 Views)

Hi nitad,

 


@nitad54449 wrote:

I don't get it: why 1E-3 and 1E-4 are shown as 0 and 1E-5 is shown as 1E-5 ?  I would expect that any number smaller than 0.01 to be either shown as 0 or switched automatically to scientific notation.


Because YOU selected "automatic formatting"!

  • 1E-3 is "automatically formatted" to 0.001, with "2 digits" shortened to 0.0, with "no trailing zeros" shortened to 0.
  • 1E-4 is "automatically formatted" to 0.0001, … (You get the point.)
  • 1E-5 is "automatically formatted" to 1E-5, with "2 digits" to 1.0E-5, without trailing zeros to 1E-5…

@nitad54449 wrote:

 I would expect that…


Your expectation is wrong.

Instead of "expecting" you should either validate with the current implementation - or use explicite formatting specifiers (like %f or %g)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 18
(549 Views)

 

I understand why the 0.001 and 0.0001 are both translated to 0 in the context of 2 precision digits ("Automatic Formatting" is converting the representation to "Floating number" and 0.001 or 0.0001 in float 2, gives 0). OK. But the automatic formatting of  0.00001 decides to represent it as 'Scientific" hence 1E-5... 

If the "Auto format" would convert the 10-5 to represent it as Float, it should also show 0.

Why the "automatic formatting"  of 0.001 does not represent it in Scientific, 1E-3 ?

 

Is there a rule for what number of digits are shown as Float or Scientific when using "Automatic Format" ?

 

nitad54449_0-1729767368631.png

 

0 Kudos
Message 6 of 18
(537 Views)

@nitad54449 wrote:

Is there a rule for what number of digits are shown as Float or Scientific when using "Automatic Format" ?

 


Of course there are "rules", but you should not care because you can always define exactly the format you want.

(And if you are really curious, you could always write a small program that iterates over various ranges so you can figure out the exact rules)

 

Quote from the help:
Automatic formatting
—Displays the numeric object in the format that LabVIEW determines is appropriate for the data. LabVIEW chooses either scientific notation or floating-point notation based on the number to format.

0 Kudos
Message 7 of 18
(522 Views)
Solution
Accepted by topic author nitad54449

@nitad54449 wrote:

 

I understand why the 0.001 and 0.0001 are both translated to 0 in the context of 2 precision digits ("Automatic Formatting" is converting the representation to "Floating number" and 0.001 or 0.0001 in float 2, gives 0). OK. But the automatic formatting of  0.00001 decides to represent it as 'Scientific" hence 1E-5... 

If the "Auto format" would convert the 10-5 to represent it as Float, it should also show 0.

Why the "automatic formatting"  of 0.001 does not represent it in Scientific, 1E-3 ?


I don't have a version of LV to look at your code.

To clarify:

Your FP data is an array of cluster, correct?

You have set the formatting of the floating point values in your cluster as "2 digits of precision without trailing 0)

Some values adhere to this (outputting 0) whereas others do not (outputting 1E-5)

Is this correct?

 

Since arrays should maintain formatting over all elements, all clusters of the array should be handled identically. And so the question is why 2 digits of precision for a floating point value is outputting 1E-5 for you.

 

I have just done the same thing in LV 2015 and see the same issue.

 

Intaris_0-1729771548424.png

 

 

To simplify things, I've used a single control with multi-line display formatting (a really cool LV feature). This removes a lot of the guesswork of the original situation.

 

This appears to be a bug in the formatting of the display for the floating point value.

 

 

0 Kudos
Message 8 of 18
(507 Views)

@Intaris wrote:
Since arrays should maintain formatting over all elements, all clusters of the array should be handled identically. And so the question is why 2 digits of precision for a floating point value is outputting 1E-5 for you.

I disagree that this is a bug.  All elements ARE handled identically in that they are automatically formatted based on LabVIEW's internal rule set. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 9 of 18
(479 Views)

Either I have some reading comprehension problems or others do.

 

If I set a digital display to have 2 digits of precision and remove trailing zeroes, it is expected that inputting a value of 0.001 results in a displayed value of 0. I think we all agree with this one.

 

But with the SAME settings, why does a value of 0.0001 lead to 1E-5 instead of 0.

 

Why does changing the value in the control from 0.0001 to 0.00001 make the displayed value (2 digits of precision and removing trailing zeroes) go from "0" to "1E-5"? Where is the consistency in this? How is this any kind of expected behaviour? What's the logic behind it? Why is 0.0001 not "1E-4" instead of "0"

Message 10 of 18
(469 Views)