Creating an array of floating point values

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Creating an array of floating point values

Post by pwr » Sun Jun 14, 2009 9:20 pm

I have the following function in Revolution:

function h1_pT p, T
--
put 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 8, 8, 21, 23, 29, 30, 31, 32 into I1
put -2, -1, 0, 1, 2, 3, 4, 5, -9, -7, -1, 0, 1, 3, -3, 0, 1, 3, 17, -4, 0, 6, -5, -2, 10, -8, -11, -6, -29, -31, -38, -39, -40, -41 into J1
put 0.14632971213167, -0.84548187169114, -3.756360367204, 3.3855169168385, -0.95791963387872, 0.15772038513228, \
-1.6616417199501E-2, 8.1214629983568E-04, 2.8319080123804E-04, -6.0706301565874E-04, -1.8990068218419E-02, \
-3.2529748770505E-02, -2.1841717175414E-02, -5.283835796993E-05, -4.7184321073267E-04, -3.0001780793026E-04, \
4.7661393906987E-05, -4.4141845330846E-06, -7.2694996297594E-16, -3.1679644845054E-05, -2.8270797985312E-06, \
-8.5205128120103E-10, -2.2425281908E-06, -6.5171222895601E-07, -1.4341729937924E-13, -4.0516996860117E-07, \
-1.2734301741641E-09, -1.7424871230634E-10, -6.8762131295531E-19, 1.4478307828521E-20, 2.6335781662795E-23, \
-1.1947622640071E-23, 1.8228094581404E-24, -9.3537087292458E-26 into n1
put 0.461526 into R --kJ/(kg K)
put p / 16.53 into myPi
put 1386 / T into tau
put 0 into gamma_der_tau
--place each list into an array
split I1 by comma
split J1 by comma
split n1 by comma
repeat with i = 1 to 34
put gamma_der_tau + (n1 * (7.1 - myPi) ^ I1 * J1 * (tau - 1.222) ^ (J1 - 1)) into gamma_der_tau
end repeat
put R * T * tau * gamma_der_tau into tOut
return tOut
end h1_pT

The problem is, when I use the debugger to view my variable values the n1 array does not initialize properly. Some of the floating point values are truncated, some of the values are set to zero and others are just fine. There doesn't seem to be any consistency in what happens to the individual values.

I know Revolution has a limit on integer values, but these are floating point. Can anyone explain what the problem is????

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Jun 15, 2009 9:19 am

Dear Pwr,

What is your reason for not putting quotes around your strings?

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

pwr
Posts: 13
Joined: Thu Apr 16, 2009 8:37 pm

Post by pwr » Mon Jun 15, 2009 11:18 pm

Hi Mark,

No (good) reason. This was my first attempt at initializing a numeric array and I didn't think of the initial 'put' statement as using strings. I changed the code to use strings before my split and that seems to have fixed things.

Thanks...pwr

Post Reply