Quick... what's X / X ?
If you hadn't read the subject line you would probably say
"1, of course!". Heck, you'd factor it out if you were
reducing an equation. But for the FPU the answer is "It
depends", because if X happens to be zero the returned
result is an INDEFINITE NaN, encoded as 50% more negative
than negative infinity. (!)
I've never found this FPU behavior to be helpful, and often
found it to cause problems. I can deal with it in
"built-in" code, but for macro-scripted code written by
users it seems too much to expect. So I'm thinking of
adding a special flag that can be set via macro, which will
normally default to returning unity in the 0/0 case, but can
be set to return either 0 or INDEFINITE if they really want
one of those.
My question for the group is whether there are hidden
"gotchas" that would make this a bad idea, or at least that
need special attention or cautions for the user.
FYI, This was prompted by a script that displays a rolling
"strip chart" of measured values, along with a floating
digital readout. The user wanted to see a "transfer
function"-type ratio (response voltage over driving
voltage), which normally only varies between 0 and a bit
more than 1.00.
But at initial start-up the driving voltage was 0 on the
first pass through the script, so the digital readout
flashed the biggest negative value it could show. That in
itself would not be a problem, except that the display
auto-sizes on the initial value and thereafter increases
only as needed, and never decreases (to prevent annoying
size jitter). So the user would be left with a super-wide
display filled with mostly white space until he manually
resized it. Ugly!
Thanks, and best regards,
Bob Masta
DAQARTA v7.21
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, Pitch Track, Pitch-to-MIDI
FREE Signal Generator, DaqMusic generator
Science with your sound card!