On Mon, Jan 06, 2020 at 09:51:05AM +0100, [email protected] wrote:
> Here is a strange behaviour in Poplog 16 using round and round(sqrt(i)):
> 
>     vars i;
>     for i from 2 to 10000 do
>          [^i ^(2**i) ^(round(sqrt(2**i)))]=>;
>     endfor;
> 
> Poplog 16 throws an error for 2**126:
> """
> .....
> ** [123 10633823966279326983230456482242756608 3260954456333195264]
> ** [124 21267647932558653966460912964485513216 4611686018427387904]
> ** [125 42535295865117307932921825928971026432 6521908912666390528]
> 
> <<<<<<< System Error: Signal = 8, PC = 00000000005B31F7 >>>>>>>
> 
> 
> ;;; MISHAP - serr: SYSTEM ERROR (see above)
> ;;; FILE     :  /home/hakank/poplog/me/test_sqrt.p   LINE NUMBER:  16
> ;;; PRINT DOING
> ;;; DOING    :  round trycompile
> """

It is unintended difference between 32 and 64 bit ports.  The attached
patch fixes this.  But there seem to be other problem, I am looking
at them.

> The previous Poplog version ("Version 15.65 Sat May  5 06:42:58 CEST 2012")
> managed to handle 2**1024 without any problem, and after that it throws a
> FLOATING POINT OVERFLOW error.
> 
> If just sqrt(i) is used then Poplog16 manage to handle 2**1024, then a
> System error is thrown:
>     vars i;
>     for i from 2 to 10000 do
>          [^i ^(2**i) ^(sqrt(2**i))]=>;
>     endfor;
> 
> """
> ** [1024
> 179769313486231590772930519078902473361797697894230657273430081157732
> 6758055009631327084773224075360211201138798713933576587897688144166224
> 9284743063947412437776789342486548527630221960124609411945308295208500
> 5768838150682342462881473913110540827237163350510684586298239947245938
> 
> <<<<<<< System Error: Signal = 8, PC = 00000000005B330E >>>>>>>

Error is normal: the number is too big to fit into a float.
However, probably there should be normal MISHAP message about
overflow.

> 479716304835356329624224137216
> ;;; MISHAP - serr: SYSTEM ERROR (see above)
> ;;; FILE     :  /home/hakank/poplog/me/test_sqrt.p   LINE NUMBER:  19
> ;;; PRINT DOING
> ;;; DOING    :  => trycompile
> """
> 
> Interestingly, if 2,0**i is used then Poplog16 only mangage to 2**1023 and
> then throws an explicit FLOATING-POINT ERROR
> 
>    vars i;
>     for i from 2 to 10000 do
>          [^i ^(2**i) ^(2.0**i)]=>;
>     endfor;
> 
> """
> ....
> ** [1023
> 898846567431157953864652595394512366808988489471153286367150405788663
> 3790275048156635423866120376801056005693993569667882939488440720831124
> 6423715319737062188883946712432742638151109800623047059726541476042502
> 8844190753411712314407369565552704136185816752553422931491199736229692
> 39858152417678164812112068608 8988465674311600000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000000000000000000000.0]
> 
> ;;; MISHAP - FLOATING-POINT OVERFLOW
> ;;; INVOLVING:  2.0 1024
> ;;; FILE     :  /home/hakank/poplog/me/test_sqrt.p   LINE NUMBER:  19
> ;;; PRINT DOING
> ;;; DOING    :  ** trycompile
> """

AFAICS that is OK, already 2**1024 is too big.  I am not sure
why integer version works, probably due to rounding error,
but I need to check.

-- 
                              Waldek Hebisch
--- ../trunk/pop/extern/lib/c_core.c	2019-06-09 15:17:51.000000000 +0000
+++ pop/extern/lib/c_core.c	2020-01-06 17:55:48.639430365 +0000
@@ -635,7 +635,7 @@
 
     if (__pop_in_user_extern == -1) _exit(1);   /* outside Pop */
 
-#if defined(i386)
+#if defined(i386)||defined(__x86_64__)
     if (sig == SIGFPE) {
         extern greg_t __pop_fpe_handler;
         if (__pop_fpe_handler)

Reply via email to