Hi Kevin, hi all,

On Thu, Dec 09, 2021 at 09:40:51PM +0100, Alexander Burger wrote:
> The conversion function can easily detect the type (short or big) when
> converting to float, and overflow to bignum if necessary when converting back
> to PicoLisp numbers.
> 
> This should really be fixed ... I check it next weekend.

Done!

Now (version 21.12.12), 'native', '%@' and 'struct' accept bignums for floating
point arguments, and overflow to bignums for large floating point return values.

   : (scl 16) (load "@lib/math.l")

   : (pow 2.0 3.0)  # This worked before
   -> 80000000000000000

   : (round @)
   -> "8.000"

   : (pow 100.0 100.0)  # This did not work
   -> 
1000000000000000021421546958041957442493134746744949294176709095342291740583330369404881029347127449862957279318330932090828950478869943421594604148335480073467842242942440201823873880805647866312652703956229962072064
   : (round @)
   -> 
"100,000,000,000,000,002,142,1546,958,041,957,442,493,1347,467,449,492,941,7670,909,534,229,174,058,3330,369,404,881,029,347,1274,498,629,572,793,1833,093,209,082,895,047,8869,943,421,594,604,148,3354,800,734,678,422,4294,244,020,182,387,388,0805,647,866,312,652,703,96"


   : (exp 200.0)
   -> 
7225973768125748468397301945341163734494552068524857298000992785760626356404779312666861737888136036352

   : (log @)
   -> 2000000000000000000
   : (round @)
   -> "200.000"

Also, it returns now 'T' for values too large to be represented as a floating
point number (i.e. "infinite"), and 'NIL' for too small values.

   : (pow 1000.0 1000.0)
   -> T

   : (exp 1000.0)
   -> T

Note that for the scale there is still a maximum of 18 (i.e. a short number for
the specification 1.0). IEEE 'double' support only 15 digits anyway.

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to