Temperature conversion: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: output needs updating... -- ~~~~) |
(→{{header|REXX}}: added other temperature scales to the REXX program, added a nit at the bottom of the output. -- ~~~~) |
||
Line 240: | Line 240: | ||
* (alternate spellings with optional ''degrees''): |
* (alternate spellings with optional ''degrees''): |
||
** Centingrade, centesimal, Celsius, Celcius |
** Centingrade, centesimal, Celsius, Celcius |
||
** Delisle |
|||
** Fahrenheit |
** Fahrenheit |
||
** Kelvin |
** Kelvin |
||
** Newton |
|||
** Rankine |
** Rankine |
||
** Reaumur |
** Reaumur, Réaumur |
||
** Romer (Romer) |
|||
* multiple temperatures in a list |
* multiple temperatures in a list |
||
* comments within the list |
* comments within the list |
||
* aligned output (whole numbers and decimal fractions) |
* aligned output (whole numbers and decimal fractions) |
||
<lang rexx>/*REXX program converts |
<lang rexx>/*REXX program converts temperature for: C, D, F, N, Ra, Re, Ro, and K.*/ |
||
parse arg tList /*get specified temperature lists*/ |
parse arg tList /*get specified temperature lists*/ |
||
Line 264: | Line 267: | ||
uU=u; upper uU /*uppercase version of temp unit.*/ |
uU=u; upper uU /*uppercase version of temp unit.*/ |
||
if left(uU,7)=='DEGREES' then uU=substr(uU,8) /* |
if left(uU,7)=='DEGREES' then uU=substr(uU,8) /*redundant "degrees"? */ |
||
if left(uU,5)=='DEGREE' then uU=substr(uU,7) /* |
if left(uU,5)=='DEGREE' then uU=substr(uU,7) /* " " ? */ |
||
uU=strip(uU) |
uU=strip(uU) |
||
if \datatype(n,'N') then call serr 'illegal number:' n |
if \datatype(n,'N') then call serr 'illegal number:' n |
||
/*accept alternate spellings. */ |
/*accept alternate spellings. */ |
||
select /*convert ──► ºF temperatures. */ |
|||
when abbrev('CENTIGRADE', uU) |, |
|||
abbrev('CENTESIMAL', uU) |, |
|||
abbrev('CELSIUS' , uU) |, |
|||
abbrev('CELCIUS' , uU) then F=n * 9/5 + 32 |
|||
when abbrev('DELISLE' , uU) then F=212 -(n * 6/5) |
|||
when abbrev('FAHRENHEIT', uU) then F=n |
|||
when abbrev('KELVIN' , uU) then F=n * 9/5 - 459.67 |
|||
when abbrev('NEWTON' , uU) then F=n * 60/11 + 32 |
|||
when abbrev('RANKINE' , uU) then F=n - 459.67 |
|||
when abbrev('REAUMUR' , uU, 2) then F=n * 9/4 + 32 |
|||
when abbrev('RéAUMUR' , uU, 2) |, |
|||
abbrev('RÉAUMUR' , uU, 2) |, |
|||
abbrev('REAUMUR' , uU, 2) then F=n * 9/4 + 32 |
|||
when abbrev('ROMER' , uU, 2) then F=(n-7.5) * 27/4 + 32 |
|||
otherwise call serr 'illegal temperature scale:' u |
|||
end /*select*/ |
|||
say right(' ' x,55,"─") |
say right(' ' x,55,"─") |
||
say Tform((F - 32) / |
say Tform((F - 32) * 5/9 ) 'Celcius' |
||
say Tform( |
say Tform((212-F) * 5/6 ) 'Delisle' |
||
say Tform( |
say Tform( F ) 'Fahrenheit' |
||
say Tform( |
say Tform((F + 459.67) * 5/9 ) 'Kelvin' |
||
say Tform((F - 32 ) / |
say Tform((F - 32 ) * 11/60 ) 'Newton' |
||
say Tform( F + 459.67 ) 'Rankine' |
|||
say Tform((F - 32 ) * 4/9 ) 'Reaumur' |
|||
say Tform((F - 32 ) * 7/24 + 7.5) 'Romer' |
|||
end /*until tlist=''*/ |
end /*until tlist=''*/ |
||
Line 297: | Line 309: | ||
'''output''' when using the input of: <tt> -40C, 0 c (water freezes), 37C (body temp), 100 C (water boils), 21 degrees Kelvin, 0K (outer space?) </tt> |
'''output''' when using the input of: <tt> -40C, 0 c (water freezes), 37C (body temp), 100 C (water boils), 21 degrees Kelvin, 0K (outer space?) </tt> |
||
<pre style="overflow:scroll"> |
<pre style="overflow:scroll"> |
||
───────────────────────────────────────────────── -40C |
|||
-40 Celcius |
|||
210 Delisle |
|||
-40 Fahrenheit |
|||
233.15 Kelvin |
|||
-13.2 Newton |
|||
419.67 Rankine |
|||
-32 Reaumur |
|||
-13.5 Romer |
|||
─────────────────────────────────── 0c (water freezes) |
|||
0 Celcius |
|||
150 Delisle |
|||
32 Fahrenheit |
|||
273.15 Kelvin |
|||
0 Newton |
|||
491.67 Rankine |
|||
0 Reaumur |
|||
7.5 Romer |
|||
────────────────────────────────────── 37C (body temp) |
|||
37 Celcius |
|||
94.5 Delisle |
|||
98.6 Fahrenheit |
|||
310.15 Kelvin |
|||
12.21 Newton |
|||
558.27 Rankine |
|||
29.6 Reaumur |
|||
26.925 Romer |
|||
─────────────────────────────────── 100c (water boils) |
|||
100 Celcius |
|||
0 Delisle |
|||
212 Fahrenheit |
|||
373.15 Kelvin |
|||
33 Newton |
|||
671.67 Rankine |
|||
80 Reaumur |
|||
60 Romer |
|||
──────────────────────────────────── 21 degrees Kelvin |
|||
-252.15 Celcius |
|||
528.225 Delisle |
|||
-421.87 Fahrenheit |
|||
21 Kelvin |
|||
-83.21 Newton |
|||
37.8 Rankine |
|||
-201.72 Reaumur |
|||
-124.879 Romer |
|||
──────────────────────────────────── 0K (outer space?) |
|||
-273.15 Celcius |
|||
559.725 Delisle |
|||
-459.67 Fahrenheit |
|||
0 Kelvin |
|||
-90.14 Newton |
|||
0 Rankine |
|||
-218.52 Reaumur |
|||
-135.904 Romer |
|||
</pre> |
</pre> |
||
[Actually, water freezes at 0.000089 ºC, and boils at 99.974 ºC.] |
|||
<br><br> |