02-08-2023 03:51 AM
@rolfk wrote:
@santo_13 wrote:
I will side with @Bill, floating point numbers are only an approximation.
You are both right of course and at the same time the OP probably doesn't care about it! 😁
He wants to see his numbers in a specific way and if they are inaccurate on the 16th digit or not (that he doesn't see) he most likely couldn't care less.
As has been pointed out; if it is just a display question on the front panel, then adjust in the control the number of digits to display. If it is about writing strings, adjust the precision of the format specifier accordingly. And if it is indeed about calculation, then use Derrick's routine. With or without Derrick's routine, the numbers are approximations anyhow, so that routine doesn't make things substantially worse and if it is what is desired, then so be it.
For this specific case some code is needed since he seems to want truncation. The display precision does perform an arithmetic rounding (more precisely the Banker's rounding where 0.5 is rounded to the next even number). This is also the default rounding mode for IEEE 754 floating point numbers.
How did I even forget about the various number to string methods? Truth be told, I'm at N+1 at work right now, and my brain's a bit scrambled these days.
02-08-2023 04:27 AM - edited 02-08-2023 04:28 AM
@MaSta wrote:
How man places to show can also be programmed via a property node. I a test it didn't work for me, seems to be a bug in LV 2015.
Doing it manually in the indicator properties dialog worked.
I usually use the Format String:
But it does a bankers rounding, while the OP wanted truncation.
02-08-2023 04:54 AM
That's what I overlooked, he wanted to always round down. Then it could be like this:
02-08-2023 04:59 AM
@MaSta wrote:
That's what I overlooked, he wanted to always round down. Then it could be like this:
It could, but you better don't try that in a tight computing loop :-). It's as inefficient as it can get with all those number to string conversion, string subset creation and then returning back to a number. That's quite the memory manager stress tester! 🙂
02-08-2023 10:47 AM
Seems like I'm a bit lost here. If a test engineer only wants to see 2 decimal places, and floating point is an approximation but it's the value we have, what do 15 positions past what we're concerned with matter for?
02-08-2023 10:48 AM
Is everyone here a Bynar?
02-08-2023 10:51 AM - edited 02-08-2023 10:56 AM
@IlluminatedG wrote:
Seems like I'm a bit lost here. If a test engineer only wants to see 2 decimal places, and floating point is an approximation but it's the value we have, what do 15 positions past what we're concerned with matter for?
There was no mention of whether or this was just for display or for calculations (e.g., compare to two decimal places) so... And if you truly believed that the OP was just asking to see two decimal places, my all the "fancy" calculations? (And don't tell me a tale about "round down" because your calculations show round to nearest.)
02-08-2023 01:19 PM - edited 02-08-2023 01:45 PM
Oh I am going to chime in!
Computers are digital! So, they cannot form an analog number strip.
IEEE 754 agreed upon a standard for floating point math functions for computing. Those "Standards" are reasonable but not purely correct.
Purely correct mathematical calculations would require HARDWARE that does not exist.
Well, that is not true! If you want hardware capable of correct pure math. Break out your "Slip-Stick" and oil it up!
You can be a Chamillionaire if you get 3 precise digits off of yours! 15 significant digits is enough to calculate the circumference of the Milky Way Galixy to a neutron diameter.
02-09-2023 01:16 AM
@JÞB wrote:
Oh I am going to chime in!
Computers are digital! So, they cannot form an analog number strip.
IEEE 754 agreed upon a standard for floating point math functions for computing. Those "Standards" are reasonable but not purely correct.
Purely correct mathematical calculations would require HARDWARE that does not exist.
Well, that is not true! If you want hardware capable of correct pure math. Break out your "Slip-Stick" and oil it up!
You can be a Chamillionaire if you get 3 precise digits off of yours! 15 significant digits is enough to calculate the circumference of the Milky Way Galixy to a neutron diameter.
I thought I read somewhere that they really only calculate pi to two decimal places for most space slingshot calculations.
02-09-2023 08:10 AM
@billko wrote:
@JÞB wrote:
Oh I am going to chime in!
Computers are digital! So, they cannot form an analog number strip.
IEEE 754 agreed upon a standard for floating point math functions for computing. Those "Standards" are reasonable but not purely correct.
Purely correct mathematical calculations would require HARDWARE that does not exist.
Well, that is not true! If you want hardware capable of correct pure math. Break out your "Slip-Stick" and oil it up!
You can be a Chamillionaire if you get 3 precise digits off of yours! 15 significant digits is enough to calculate the circumference of the Milky Way Galixy to a neutron diameter.
I thought I read somewhere that they really only calculate pi to two decimal places for most space slingshot calculations.
I thought they rounded to 1.