T
Tabby
Guest
On Sunday, 8 May 2022 at 22:52:03 UTC+1, jla...@highlandsniptechnology.com wrote:
Yup. Though if we are to be pedantic, the correct answers generally are a number, but the CPU is unable to calculate or report them.
On Sun, 8 May 2022 13:44:45 -0700 (PDT), Tabby <tabb...@gmail.com
wrote:
On Saturday, 30 April 2022 at 16:31:51 UTC+1, Skybuck Flying wrote:
When exception masks are all enabled to stop the processor from throwing floating point exceptions the following calculation produces a somewhat strange result:
0.0 / 0.0 = -nan
(At least in Delphi).
For now I will assume this is the case in C/C++ as well and with that I mean on x86/x64 which should and seems to be following IEEE 754 floating-point format.
I am a little bit surprised by this and I want/need to know more. Where is this defined that 0.0 / 0.0 should be -NAN ?!?
Problem is with the code, example:
T := 0;
D := 0.0 / 0.0;
P := T * D;
This screws up P. instead of P being zero, P is now also -NAN ?!?
I find this very strange but ok.
I guess a simple solution could be to set D to 0 explicitly for this case, is there perhaps another solution ? Maybe some kind of mask or rounding mode so that additional branch is not necessary ???
Bye for now,
Skybuck.
I can\'t remember where NAN is from, but it means the answer can not be computed.
Not A Number.
Yup. Though if we are to be pedantic, the correct answers generally are a number, but the CPU is unable to calculate or report them.