Hi i write because iam use classpad Lua, and when i call the pack "CAS" ,require("cas"), its possible to show in the screen a decimal number??
For example when i introduce any thing similar to:
z=0
x=0
repeat
x=x+1
z=getkey()
until z==K_DOWN
print((60*x)/181008)
y=((60*x)/181008)
require("cas")
print(cas.todms(y/3600))
when the calculation terminate print in the screen this
1.0060........--(any number, its an example)
dms(0,0,31438527579/31250000000)
its possible to change this (31438527579/31250000000) into a decimal number, not fracctionary??
Other Question is the command ans its aviable in cplua??
What are the programs or utilities for CPLUA??
Thank you
Fabri
Cas Fraction Calculation?
Started by
Fabri
, Mar 30 2006 01:05 AM
5 replies to this topic
#1
Posted 30 March 2006 - 01:05 AM
#2
Posted 30 March 2006 - 04:28 AM
Use
Value of ANS is held in cas variable called 'ans', to get acces to this value use
or like it was earlier:print( cas.todms(y/3600)() )
as You prefer...print( cas.todms(y/3600)(0) )
Value of ANS is held in cas variable called 'ans', to get acces to this value use
it should workcas("ans")
#3
Posted 30 March 2006 - 08:41 AM
Indeed, "cas.todms(y/3600)" returns a CAS expression containing a decimal number; to transform it into a simple Lua number you have to call it by adding a couple of parenthesis behind
Thus,
By the way, in your code you could use
There are already some utilities and program written for CPLua, check in this forum to see some examples. Don't miss LuaNumAn too
Thus,
a = cas("3/4") -- 'a' is a CAS expression print(a) -- prints "3/4" print(a()) -- prints "0.75"
By the way, in your code you could use
waitkey(K_DOWN)instead of
z=getkey() until z==K_DOWNYou won't use too much battery this way
There are already some utilities and program written for CPLua, check in this forum to see some examples. Don't miss LuaNumAn too
#4
Posted 30 March 2006 - 08:47 PM
Hi thank you for response my questions but my problem continue, when i write yours code:
print( cas.todms(y/3600)(0) )
appears on the screen only a decimal number, and not appears this
"dms(0,0,31438527579/31250000000)" i want to appear this but i only see a decimal number with no "dms(0,0,...)" zero (0) number its an examples because this are change if it needed
print( cas.todms(y/3600)(0) )
appears on the screen only a decimal number, and not appears this
"dms(0,0,31438527579/31250000000)" i want to appear this but i only see a decimal number with no "dms(0,0,...)" zero (0) number its an examples because this are change if it needed
#5
Posted 30 March 2006 - 09:11 PM
I must admit that I have no idea how to do it... I tried with
but it doesnt work..... and Im also wondering now how to do it... Orwell? Pap???cas.elem( cas.getRight( res ), 1)
#6
Posted 30 March 2006 - 09:55 PM
Hi Thank you everybody , this program are a little cronograph its display the time in seconds and display the time in dms(hours(degrees), minutes, seconds), its a great utility for me when I take an intervale of time, I hope that you copy, paste my source program and try this in yours classpads
and solve this problem, the dms().
z=0
x=0
print("Push to Start")
waitkey(K_UP)
clear()
print("Push [v] to Stop")
repeat
x=x+1
z=getkey()
until z==K_DOWN
print("")
print((60*x)/181008)
y=((60*x)/181008)
require("cas")
print("")
print(cas.todms(y/3600))
print("\n")
Grettings ()
Fabri
and solve this problem, the dms().
z=0
x=0
print("Push to Start")
waitkey(K_UP)
clear()
print("Push [v] to Stop")
repeat
x=x+1
z=getkey()
until z==K_DOWN
print("")
print((60*x)/181008)
y=((60*x)/181008)
require("cas")
print("")
print(cas.todms(y/3600))
print("\n")
Grettings ()
Fabri
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users