My Calculator project doesn't seem to work. I am trying to make decimal numbers work and so far this is my script:
Decimal point button:
<when[ Decimal Button ]clicked>
<set{ Decimal }to( 1 )>
Number 1 button
<when[ 1 ]clicked>
<if><( <{ Decimal }> <=> 0 )>
<set{ Calculator Display }to( (( Calculator Display <*> 10 ))>
<change{ <{ Calculator Display }> }by( 1 )>
<else>
<change{ <{ Calculator Display }> }by( (( 1 </> 10^ Decimal )) (Didn't know how to get 10^ block)
<change{ <{ Decimal }> }by( 1 )>
It works once to get X.1 but I can't get X.11 ect. any reason why?
Offline
I never exactly got around to adding decimal points in my calculator... at least it has decimal point answers to division problems such as 2/1.
Anyway, I played around with this for a while and remembered the exact reason I didn't use a variable before; they won't set to something such as 1.111111 very well (I did some tests and got something wacky such as 1.2111111e). I used a list instead, and came up with:
When Green Flag Clicked:
delete all of numbers
delete all of decimal
add [0] to decimal
add { } to numbers
When Space Key Pressed:
if item 1 of decimal ( < [10])
replace (item 1 of decimal) with [10]
When 1 Key Pressed:
if item 1 of decimal (< [0])
repeat until (((item 1 of numbers) mod [1]) = [0])
replace (item 1 of numbers) with ((item 1 of numbers) * [10])
replace (item 1 of numbers) with ((((item 1 of numbers) * [10]) + [1]) / Decimal)
replace (item 1 of decimal) with ((item 1 of decimal) * [10])
else
replace (item 1 of numbers) with (((item 1 of numbers) * [10]) + [1])
Sorry that I couldn't use the forum blocks; there aren't any list ones, and also; sorry for making this post all weird.
Anyway, hope this helps!
Last edited by Chrischb (2009-06-23 01:40:15)
Offline