10-15-2007 09:33 AM
10-15-2007 10:27 AM
Basically, I hope the discussion helps result in the development of some utility vi's that do appropriate rounding for operations like Q-R and floating-point comparison. I for one would expect to use them now and then. At this stage of the game though, it's apparent I don't know enough IEEE to be much help at developing them.
Can anyone propose some ideas on how to both specify and implement rounding for SGL and DBL values?
-Kevin P.
10-15-2007 04:11 PM
10-15-2007 05:36 PM
Shane,
I agree that a best-case scenario is a "home-brew toolkit" like you mentioned, but one that goes through some significant rigor and then makes its way into OpenG.
It *does* seem there will always be some corner cases that can be imagined. That's ok with me so far, because I don't view any of these alternative "rounded" functions as replacements for the standard ones. If the input values are of unknown origin or unknown precision, the standard functions should be preferred since they operate in a well-defined industry-accepted manner.
However, in certain instances inputs are known to have limited meaningful precision. *Then* a programmer could have the option of choosing one of these alternative toolbox functions. What remains is to demonstrate that a well-implemented alternative function won't merely shift the problem and cause a *different* distinct set of common inputs to result in non-intuitive outputs. I'm not convinced yet, but am willing to consider it may be possible. I'm hoping it *is* possible, because I'd like to use such functions.
I guess the key test is that you don't want to observe a discontinuity in the output caused by a change in an input that's confined to bits/digits well to the right of its last significant digit. 1 good counter-example would blow the whole exercise out of the water.
-Kevin P.
10-15-2007 06:44 PM
10-17-2007 10:54 AM - edited 10-17-2007 10:54 AM
Message Edited by Anthony de Vries on 10-17-2007 05:56 PM
10-17-2007 11:37 AM
Gerd,
how to "be sure that rounding errors will never reach" your precision level? Something like:
When you do 5 math steps you get 6 digits precision, but after 10 steps only 4 digits? When you include trigonometric functions you get one digit less precision?
True, that's an issue. However, it's not like you don't have that problem allready. Do you write your end results in 16 sign. digits on the front panel or in files? Or do you round them? To which number of sign. number do you round? Have you checked wether the rounding errors have reached that precision level?
How is rounding before comparisons different?
But ofcourse, that the reason why I suggested that you have the option to choose between IEEE and rounded, and to set the rounding. Then you just need to pick a suitable default. 8 or 10 sign. digits probably suits most needs. You need to do A LOT of calculations before you produce 6 to 8 digits of rounding errors.
Anyway... if you get more than that, you're only just back to the unexpected results you allready got from the IEEE primitives, which apparantly most don't feel as a problem...
10-18-2007 02:22 AM
10-18-2007 05:17 AM
Indeed, there's very few meaurements that have more than 7 sign. digits of precision. Mosts phyisical constant, like the speed of light, gravitional constant etc, only have 8 to 9 sign. digits, because we simply couldn't measure them more accurately.
But here's the thing... When your measurement is only significant to max. 7 digits.... why compare values in a way that is dependend on the 15's digit?
Having an option to include the rounding is just a service to users. It doesn't change IEEE compliance. You could keep the default at IEEE compliance to prevent such questions.
Sure, you can ask people to do their own rounding before using the IEEE primitives. People would then make their own set of extended primitives, like I have done with the QR, and Kevin has done for floating point equality. Then these extended vi's sit in the user library.
Obviously, NI could also choose to include such a set of extended primitive themselves, as a service to their customers, so people wouldn't have to program it themselves. Then, these extended vi's sit in an 'advanced section' of the 'numeric' menu. No problem with that, is there?
But then, you have a double set of comparison primitives in the menu structure. To keep the menu structure cleaner, NI could choose to make the comparison primitives polymorphic, so you can choose between IEEE en rounded, in stead of having two seperate menu's. It's really the same as having a seperate library, just a different way of choosing them.
Having them polymorphic, would allow for a 'default' choice in the Laview options, where one could select that you want the rounded version default, instead of the IEEE version. Again, that's simply making it more easy to select those vi's from the menu structures. Keep the default installation setting at IEEE, and nothing is different from before.
It's just a matter of where and how you place things in the menu, nothing more.
10-18-2007 05:45 AM
<Cluster>
<Name></Name>
<NumElts>1</NumElts>
<DBL>
<Name></Name>
<Val>3.14159</Val>
</DBL>
</Cluster>