Author Topic: Validity of floating point numbers without FPU code  (Read 9413 times)

sinsi

  • Guest
Re: Validity of floating point numbers without FPU code
« Reply #15 on: January 06, 2015, 01:33:01 PM »
 :biggrin:
I wouldn't start using win10 exclusively yet, there are still a few things that break (like my software raid0 array set up in win7).
There's supposed to be a "significant" upgrade later this month so we'll see.

Gunther, the latest version works OK in 64-bit win10 with similar times.

rrr314159

  • Member
  • *****
  • Posts: 1382
Re: Validity of floating point numbers without FPU code
« Reply #16 on: January 06, 2015, 03:00:30 PM »
Windows 8.1 x64 AMD A6-6310 APU 1.8 GHz
and
Windows 8 x64 i5-3330 @3.00GHz

Code: [Select]
Windows 8.1 x64 AMD A6-6310 APU 1.8 GHz

The C macro isfinite() returns whether X is a finite value.
A finite value is any floating point value that  is neither
infinite nor NaN (Not a Number).
The type of X shall  be float, double or  long double. A non
zero value (true) if X is finite; and zero (false) otherwise.
Here are some examples:

isfinite(0.0)        = 1
isfinite(1.0/0.0)    = 0
isfinite(-2.0/0.0)   = 0
isfinite(sqrt(-4.0)) = 0

Please, press enter to continue...
The different checks may take a while.

Checking the REAL4 number 3.141593:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     10.92 s         4.38 s

Please, press enter to continue...

Checking the REAL8 number 3.141592653589793:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     13.78 s         4.62 s

Please, press enter to continue...

Checking the REAL10 number 3.1415926535897932385:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     19.26 s         5.39 s

-------------------------------------------------------------
-------------------------------------------------------------

Windows 8 x64 i5-3330 @3.00GHz

Checking the REAL4 number 3.141593:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     5.39 s          2.38 s

Please, press enter to continue...

Checking the REAL8 number 3.141592653589793:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     5.75 s          2.41 s

Please, press enter to continue...

Checking the REAL10 number 3.1415926535897932385:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     6.61 s          3.03 s

I am NaN ;)

habran

  • Member
  • *****
  • Posts: 1225
    • uasm
Re: Validity of floating point numbers without FPU code
« Reply #17 on: January 06, 2015, 05:02:29 PM »
Good job Gunther :t
this one runs fine

Thanks sinsi :biggrin:
Please let us know when it comes out and you test it
BTW where is your shop?
I am in Enfield. If you don't want to give address here send me a PM


Code: [Select]
The C macro isfinite() returns whether X is a finite value.
A finite value is any floating point value that  is neither
infinite nor NaN (Not a Number).
The type of X shall  be float, double or  long double. A non
zero value (true) if X is finite; and zero (false) otherwise.
Here are some examples:

isfinite(0.0)        = 1
isfinite(1.0/0.0)    = 0
isfinite(-2.0/0.0)   = 0
isfinite(sqrt(-4.0)) = 0

Please, press enter to continue...
The different checks may take a while.

Checking the REAL4 number 3.141593:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     3.58 s          1.94 s

Please, press enter to continue...

Checking the REAL8 number 3.141592653589793:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     4.14 s          1.92 s

Please, press enter to continue...

Checking the REAL10 number 3.1415926535897932385:
It's a finite floating point value.

         C-version       Assembly Language
         ---------       -----------------
Time     5.99 s          2.23 s

Please, press enter to end the application ...
Cod-Father

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Validity of floating point numbers without FPU code
« Reply #18 on: January 07, 2015, 07:06:02 AM »
Hi sinsi,

I wouldn't start using win10 exclusively yet, there are still a few things that break (like my software raid0 array set up in win7).
There's supposed to be a "significant" upgrade later this month so we'll see.

Gunther, the latest version works OK in 64-bit win10 with similar times.

thank you for testing. I trust you sinsi, so let's wait until the new update is arriving.

rrr314159 and Habran

thanks for testing the new version. I think I can update the driver, because it's curruntly running with the slow macro version for REAL10 values. I am relieved.

Gunther
Get your facts first, and then you can distort them.

Antariy

  • Member
  • ****
  • Posts: 551
Re: Validity of floating point numbers without FPU code
« Reply #19 on: January 08, 2015, 06:56:03 AM »
Just as an interesting info, after reading this thread and another, related to it (sorry for no timings, Gunther, my system is 32 bit, as you know), I thought about another way to test validity of float/double. This method "derived" from this my code http://masm32.com/board/index.php?topic=2242.msg23112#msg23112
Now some info and then what I've found.
CMPPS and CMPPD instructions in the equality comparsion mode (the immediate byte is 0) have the specification that they return false as a result of comparsion of the numbers where operand is NaN. No exceptions are raised also.

But now, if we compare the number with raw hex value as 0x7FF0000000000000 with itself, we get TRUE result. But the number is NaN, so there is "bug" in this SSE instruction? The same if the number is 0x7F80000000000000 (infinity) - the result is wrong.
If we compare the number, for an instance, 0x7FF0000000000001 with itself, then instruction works OK and returns true. But is there reason why it returns not proper result for 0x7FF0000000000000?

If not that bug, is it such or not, it would have possible to use these pieces as a check for finity.

Code: [Select]
Check float for finity:

cmpps xmm0,xmm0,0
movd eax,xmm0
ret

Check double for finity:

cmppd xmm0,xmm0,0
movd eax,xmm0
ret


qWord

  • Member
  • *****
  • Posts: 1476
  • The base type of a type is the type itself
    • SmplMath macros
Re: Validity of floating point numbers without FPU code
« Reply #20 on: January 08, 2015, 08:18:54 AM »
But now, if we compare the number with raw hex value as 0x7FF0000000000000 with itself, we get TRUE result. But the number is NaN, so there is "bug" in this SSE instruction?
If you are referring to a double value (REAL8, binary64), it is the encoding for +∞, which can be compared.
MREAL macros - when you need floating point arithmetic while assembling!

Antariy

  • Member
  • ****
  • Posts: 551
Re: Validity of floating point numbers without FPU code
« Reply #21 on: January 08, 2015, 08:46:04 AM »
If you are referring to a double value (REAL8, binary64), it is the encoding for +∞, which can be compared.

As double, you get right. Thanks for explanation :t

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Validity of floating point numbers without FPU code
« Reply #22 on: January 08, 2015, 09:52:59 PM »
Hi Alex,

good to see you again after a long time.  :t

Just as an interesting info, after reading this thread and another, related to it (sorry for no timings, Gunther, my system is 32 bit, as you know), I thought about another way to test validity of float/double. This method "derived" from this my code http://masm32.com/board/index.php?topic=2242.msg23112#msg23112

Never mind. I know your thread (I've posted in). I think that qWord gave the right answer. The idea for the code which I've used came from qWord, too.

Gunther
Get your facts first, and then you can distort them.

rrr314159

  • Member
  • *****
  • Posts: 1382
Re: Validity of floating point numbers without FPU code
« Reply #23 on: January 08, 2015, 10:06:18 PM »
Gunther, it's not even worth mentioning, but in your CheckFpNum.asm the comments for two of the CheckIn... routines are not right. All three say the purpose is to check if the REAL 4 number is finite, but the last two should say 8 and 10, of course.
I am NaN ;)

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Validity of floating point numbers without FPU code
« Reply #24 on: January 08, 2015, 11:33:54 PM »
rrr314159,

you're right. What can I say? It's the result of my laziness - you know: copy & paste. But in the original driver code (that's made with the inline assembler) and inside the documentation it is right.

Gunther
Get your facts first, and then you can distort them.