Hi Sundar,

> Is there a mailing list for beginners learning this language or can they
> pose questions here.

Here is fine :)


> I am facing a challenge to figure this out,
> 
> : (setq *Scl 2)
> -> 2
> : (** (+ 1.0 0.01) 24)
> -> 1269734648531914468903714880493455422104626762401
> 
> Now, how to get the correct result of the computation ( 1.01 ^ 24 =
> 1.26....)
> : (*/ (** (+ 1.0 0.01) 24) ?? ??)

As you probably know, for fixpoint calculation as in PicoLisp it is necessary to
divide by 1.0 after each step:

   : (*/ 3.0 4.0 1.0)
   -> 1200
   : (round @)
   -> "12.00"

Therefore, after exponentiation, you need to divide the result by ten power the
exponent minus one:

   : (round (*/ (** 2.0 3) (** 1.0 2)))
   -> "8.00"


We could make a general fixpoint exponentiation function

   : (de f** (N E)
      (*/
         (** N E)
         (** 1.0 (dec E)) ) )

   : (round (f** 2.0 3))
   -> "8.00"

   : (round (f** (+ 1.0 0.01) 24))
   -> "1.27"

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe

Reply via email to