Friday, January 16, 2009

tiny-Celsius


I took a pic of our outdoor thermometer this morning at 5:30 AM, just to verify the 5th run (in red) of budding tiny-c programmer Max's first real application in this programming language. It's probably not obvious when you look at the code below, but a tremendous amount of effort went into this and, if you ask me, this star-generating machine is just about due to get one from me.

/* cnvfc.tc - ceb - ver 2.15 - 1/16/9

cnvfc [
pl "Enter a whole number Fahrenheit temperature to convert to Celsius : "
int f,c
f=gn
c=(5*f-160)/9
pl "";pn f;ps" F =";pn c;ps" C";pl ""
]

tc>.r cnvfc.tc
189
0 10 189 89811
tc>.cnvfc

Enter a whole number Fahrenheit temperature to convert to Celsius : 30

30 F = -1 C

tc>.cnvfc

Enter a whole number Fahrenheit temperature to convert to Celsius : 34

34 F = 1 C

tc>.cnvfc

Enter a whole number Fahrenheit temperature to convert to Celsius : 213

213 F = 100 C

tc>.cnvfc

Enter a whole number Fahrenheit temperature to convert to Celsius : 79

79 F = 26 C

tc>.cnvfc

Enter a whole number Fahrenheit temperature to convert to Celsius : 0

0 F = -17 C

tc>

5 comments:

Tobee 'n DeeDee said...

Purdy cool (pun intended).

Tinyc Tim said...

(Dais iz axshully frum Max butz hiz fingahs gotz fwozed tah hiz keeboard doo tah da -4 dugree Fairenhyte tempachur zo he axed mee tah poast id foah him.)

Translation by Toby Speak Version 2.2n
The dishunary contains 1406 wurds.

I agree with you, DeeDee. It is very "cool." We got down to -4 here in Marborrow this morning!

I wanted to share my second new tiny-c program (which converts F degrees to C degrees) with everyone. It's cool too and TcT gave me some hints to write it.
I can now say it works! Here is what it looks like after making it look pretty. It is for a calculation on my Marborrow temp of -4 today.

Tobee 'n DeeDee said...

It was -15 here in Portland this morning. What is that in Celsius?

Tinyc Tim said...

Looking at the thermometer in hi-resolution (by clicking it) I'd put it at -26 C. Doing the math, using Max's formula, (5*(-15)-160)/9 = -235/9 = -(26 1/9) = approx. -26.11.

Basically, very very cold!

And if that isn't accurate enough for you, a special version of an F to C converter in tiny-c gives ...

F -> C (type F) or C -> F (type C) f

Enter F (e.g. 73, 0) : -15

C is -26.111111111111111111111111111
1111111111111111111111111111111111
1111111111111111111111111111111111
11111

Hey, I just heard something about Montpelier being -25 F.

Tobee 'n DeeDee said...

It was -31 F where my mom lives in northern Maine last night!