10-24-2024 03:48 AM
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 :
So, I would expect that 0.001 appears as 1E-3. To my surprise, for these values
I get these results.
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
Solved! Go to Solution.
10-24-2024 04:13 AM
0.001 written with 2 decimal places is 0. You probably want 2 significant digits mode.
10-24-2024 04:14 AM - edited 10-24-2024 04:14 AM
Hi Nitad,
@nitad54449 wrote:
Is it me …?
Yes.
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"…
10-24-2024 05:08 AM - edited 10-24-2024 05:11 AM
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.
10-24-2024 05:26 AM - edited 10-24-2024 05:29 AM
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"!
@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)!
10-24-2024 06:00 AM - edited 10-24-2024 06:02 AM
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" ?
10-24-2024 06:46 AM
@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.
10-24-2024 07:06 AM - edited 10-24-2024 07:07 AM
@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.
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.
10-24-2024 09:38 AM
@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.
10-24-2024 09:48 AM - edited 10-24-2024 09:50 AM
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"