Author |
Message |
aldreneo
|
Posted: Mon Jun 19, 2006 2:25 pm Post subject: Math with decimals |
|
|
code: |
var number1:int
get numberone
numberone * 2
print numberone
|
How do I make it so that numberone has a decimal in it and still be able to do math with it?
Example output I would like:
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
r.3volved
|
Posted: Mon Jun 19, 2006 2:45 pm Post subject: (No subject) |
|
|
Data type of integer uses whole numbers with no decimal places.
so your datatype should be (been a long time since I used hideous turing) Double, Float, Real or Decimal...whatever turing uses |
|
|
|
|
|
Delos
|
Posted: Mon Jun 19, 2006 2:46 pm Post subject: (No subject) |
|
|
You could simply use real variables instead:
code: |
var real_number : real
|
Also, you don't print output in Turing, you put it . |
|
|
|
|
|
aldreneo
|
Posted: Mon Jun 19, 2006 3:05 pm Post subject: (No subject) |
|
|
Thanks
And allmost every other language uses print why does turing use put? |
|
|
|
|
|
Delos
|
Posted: Mon Jun 19, 2006 3:35 pm Post subject: (No subject) |
|
|
Why does Ruby use 'puts'? I'm not sure there's a satisfactory answer to that. If it makes you feel better, you could add this to an Output module:
code: |
procedure print (text : string)
put text
end print
% And add others for ints, reals, etc, since Turing can't handle function overloading.
|
|
|
|
|
|
|
s3arkay
|
Posted: Mon Jun 19, 2006 3:43 pm Post subject: (No subject) |
|
|
code: |
var num : real
get real
put real :0:2
|
That would print the number with 2 decimals even if it didnt have any,
Example : 2.00 |
|
|
|
|
|
aldreneo
|
Posted: Tue Jun 20, 2006 9:33 am Post subject: (No subject) |
|
|
but, that would be without rounding
s3arkay wrote: code: |
var num : real
get real
put real :0:2
|
That would print the number with 2 decimals even if it didnt have any,
Example : 2.00 |
|
|
|
|
|
|