Not quite true...

Lingo Help sez :
floatPrecision:
Movie property; rounds off the display of floating-point numbers to the
number of decimal places specified. The value of floatPrecision must be an
integer. The maximum value is 15 significant digits; the default value is 4.

The floatPrecision property determines only the number of digits used to
display floating-point numbers; it does not change the number of digits used
to perform calculations.

Meaning that it only changes the floatprezion for the displaying of
floatingpoint data.

Example:
step 1: high floatprecision:
the floatprecision = 10

c = 1.5

put c*c
-- 2.2500000000

step 2: 0 floatPrecision
the floatprecision = 0
put c*c
-- 2
-- Showing only the value before the decimal point

put (c*c)*4
-- 9
-- showing that the data after the decimal point has infact not been lost.

Pekka Buttler



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Jonatan Wallgren
> Sent: 15. kes�kuuta 2001 12:32
> To: [EMAIL PROTECTED]
> Subject: SV: <lingo-l> returned value from function
>
>
> Hi Ellen
>
> I haven�t checked the code thoroughly but I think it's a floatprecision
> problem. When you have a floatprecision of 4 then director only uses four
> decimals in all calculations, so when you convert a string like this
> "0.123456789" with the value command the actual value you get is
> 0.1234 when
> the floatprecision 4. So try set the floatprecision to 14 (it's
> actually the
> maximum floatprecision value) and format the number when you want
> to display
> it.
>
> -----------------------------------------
> Jonatan Wallgren Multimediaproducent
> [EMAIL PROTECTED]
>
> Xtractor Interactive AB
> Br�nnkyrkagatan 70
> 118 23 STOCKHOLM
>
> Tel +46 8 668 18 20
> Fax  +46 8 668 18 26
> Mobil +46 733 84 30 90
> http://www.xtractor.se/
> -----------------------------------------
>
> -----Ursprungligt meddelande-----
> Fr�n: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]F�r
> Ellen C. Largo
> Skickat: den 16 juni 2001 02:09
> Till: [EMAIL PROTECTED]
> �mne: <lingo-l> returned value from function
>
>
> Hello lists,
>
>       I have this problem with the values returned after calling
> a function
> handler.  Below are the handler definitions.
>
> ----this is the handler that calls the function cum1_compute
>
> on compute_prices
>
>  -- global variable declarations
>
>   global s, x, vola, rate, div, days
>   global vola1, rate1, div1, timeperiod, d1, d2
>   global cvalue1, cvalue2, callprice, putprice
>   global pvalue1, pvalue2, pargu1, pargu2
>
>   --set the floatprecision that is the number of decimals to be displayed
>
>   the floatPrecision = 4
>
>   --convert field to numeric values
>
>   s = float(value(member("StkP").text))
>   x = float(value(member("Strike Price").text))
>   vola = float(value(member("Volatility").text))
>   rate = float(value(member("Interest rate").text))
>   div = float(value(member("Dividends").text))
>   days = float(value(member("day").text))
>
>
>   vola1 = vola/100.0
>   rate1 = rate/100.0
>   divi1 = div/100.0
>   timeperiod =days/365.0
>
>
>   d1 = float((log(s/x) + ((rate1 - divi1 + 0.5 * vola1 * vola1) *
> timeperiod))/(vola1 * power(timeperiod, 2)))
>   d2 = float(d1 - vola1 * power(timeperiod,2))
>
>
>   ---computes for call price
>
>   cvalue1 = float(1.0 * (s * exp(-(divi1) * timeperiod)) *\
>              cum1_comput(1.0 * d1)) -- this part calls the function
>   cvalue2 = float(1.0 * (x * exp(-(rate1) * timeperiod)) *\
>               cum1_compute(1.0 * d2)) --- calls the function
> again with                                                    diff.
> value of parameter passed
>   callprice = float(cvalue1 - cvalue2)
>
>
>   --computes for put price
>
>    pvalue1 = float(-(1.0) * s * exp(-(divi1) * timeperiod) * \
>               cum1_compute(-(1.0) * d1))
>   pvalue2 = float(-(1.0) * x * exp(-(rate1) * timeperiod) * \
>               cum1_compute(-(1.0) * d2))
>
>   putprice = float(pvalue1 - pvalue2)
>
>   --display answer to fields
>
>   put putprice into field "Put Price"
>   put callprice into field "Call Price"
>
> end
>
> -----the function handler definition
>
> on cum1_compute value_param
>
>   --make a list of constant yy values
>   yy=[:]
>   yy = ["0.31938153","-(0.356563782)","1.781477937",\
>        "-(1.821255978)","1.330274429"]
>
>   gamma=0.2316419
>
>
>   pi2 = float(2*pi)
>   expovalue = float(-(value_param)*(value_param*0.5))
>   fak = float(1/power(pi2, 2)) * float(exp(expovalue))
>
>   z = float(1/(1+(gamma * abs(value_param))))
>
>   fak1 = float(z * value(yy[5]))
>   repeat with i = 4 down to 1
>     fak1 = float(z * float(fak1 + value(yy[i])))
>   end repeat
>
>   cum1 = float(1.0 - fak*fak1)
>
>   if (value_param < 0) then
>     cum1 = float(1.0 - cum1)
>   end if
>
>
>   --returns value to compute_prices handler
>   return cum1
>
> end cum1_compute
>
>
>       I tried to display the actual value computed with the
> function handler and
> also the value actually computed in the calling handler, and i
> noticed that
> the calling function is using a different value in the
> computation than what
> was passed by the function handler.
>
>       I really am confused why is this so?  Is there something
> wrong with the
> computation or the passing of values?
>
>       The original formula for this computation is given to us in
> Visual Basic
> code.
>
>       Also, is it really a must to declare variables used in
> computation to be
> global in scope?  I tried declaring the variable vola1 as local
> (set vola1 =
> 0.0) but when i test the value in the message window it returned a <VOID>
> value.  Why is this?
>
>       I would really appreciate it if you experts can help me
> solve this problem.
>
>
>
> thanks in advance,
> ellen
>
>
>
>
>
>
>
>
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>
>
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>


[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to