On Sun, 12 Mar 2023 20:44:27 +0100, Christian Gollwitzer wrote:
Am 12.03.23 um 19:54 schrieb debolina ghosh:
hi Folks,
I am a new tcl code user. I need to write a tcl code to convert
decimal into thermometer code . Any guidance ?
It's totally unclear what you mean by "decimal" and "thermometer". Can
you give a concrete example?
Christian
I bet the original poster meant from Celsius to Fahrenheit.
First, you need the formula:
https://www.calculatorsoup.com/calculators/conversions/celsius-to-fahrenheit.php
°F = °C * 9/5 + 32
In Tcl syntax,
set Fahrenheit [expr [expr Celsius * [expr 9 / 5] + 32]
Or simpler:
set Fahrenheit [expr [expr $Celsius * 1.8] + 32]
Testing:
% set Celsius 32
% set Fahrenheit [expr [expr $Celsius * 1.8] + 32]
89.6
% set Celsius 14
% set Fahrenheit [expr [expr $Celsius * 1.8] + 32]
57.2
% set Celsius 78
% set Fahrenheit [expr [expr $Celsius * 1.8] + 32]
172.4
If you want to convert from Fahrenheit to Celsius, the opposite formula
is here:
https://www.calculatorsoup.com/calculators/conversions/fahrenheit-to-celsius.php
--
Luc
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)