Jump to content



Photo

Cas Fraction Calculation?


  • Please log in to reply
5 replies to this topic

#1 Fabri

Fabri

    Newbie

  • Members
  • Pip
  • 21 posts
  • Location:Quito Ecuador

  • Calculators:
    Casio Classpad 300
    Casio fx 6300G

Posted 30 March 2006 - 02:05 AM

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

#2 -Tom-

-Tom-

    Casio Freak

  • Members
  • PipPipPipPip
  • 104 posts
  • Location:Poland
  • Interests:Tides, Celestial Navigation, Deadreckoning

  • Calculators:
    Cla$$pad 300

Posted 30 March 2006 - 05:28 AM

Use

print( cas.todms(y/3600)() )

or like it was earlier:

print( cas.todms(y/3600)(0) )

as You prefer...

Value of ANS is held in cas variable called 'ans', to get acces to this value use

cas("ans")

it should work

#3 Orwell

Orwell

    Casio Overlord

  • Members
  • PipPipPipPipPipPipPip
  • 777 posts
  • Gender:Male
  • Location:Paris - France

  • Calculators:
    Casio AFX 1.02 / Casio ClassPad 300

Posted 30 March 2006 - 09: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,
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_DOWN
You 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 Fabri

Fabri

    Newbie

  • Members
  • Pip
  • 21 posts
  • Location:Quito Ecuador

  • Calculators:
    Casio Classpad 300
    Casio fx 6300G

Posted 30 March 2006 - 09: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

#5 -Tom-

-Tom-

    Casio Freak

  • Members
  • PipPipPipPip
  • 104 posts
  • Location:Poland
  • Interests:Tides, Celestial Navigation, Deadreckoning

  • Calculators:
    Cla$$pad 300

Posted 30 March 2006 - 10:11 PM

I must admit that I have no idea how to do it... I tried with

cas.elem( cas.getRight( res ), 1)

but it doesnt work..... and Im also wondering now how to do it... Orwell? Pap???

#6 Fabri

Fabri

    Newbie

  • Members
  • Pip
  • 21 posts
  • Location:Quito Ecuador

  • Calculators:
    Casio Classpad 300
    Casio fx 6300G

Posted 30 March 2006 - 10: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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users