Convert Temperature

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Convert Temperature

15 Apr 2014, 09:04

Convert Temperature

Convert Temperature
- Celsius --> C
- Kelvin --> K
- Fahrenheit --> F
- Rankine --> Ra
- Réaumur --> Re
- Delisle --> De
- Newton --> N
- Rømer --> Ro

Source: GitHub

Code: Select all

convTemp(d, f := "C", t := "F", r := 2)
{		
    d := (f = "K") ? ((d - 273.15)) : ((f = "F") ? ((d - 32) / 1.8) : ((f = "Ra") ? ((d + 5 / 9) - 273.15) : ((f = "Re") ? ((d * 1.25))
           : ((f = "De") ? ((100 - d) * 2 / 3) : ((f = "N") ? ((d * 100 / 33)) : ((f = "Ro") ? ((d - 7.5) * 40 / 21) : d ))))))
    return round((t = "C") ? d : ((t = "K") ? ((d + 273.15)) : ((t = "F") ? ((d * 1.8) + 32) : ((t = "Ra") ? ((d + 273.15) * 1.8) : ((t = "Re") ? ((d * 0.8))
           : ((t = "De") ? ((100 - d) * 1.5) : ((t = "N") ? ((d * 1 / 3)) : ((t = "Ro") ? ((d * 0.525) + 7.5) : "" ))))))), r)
}

MsgBox, % convTemp(80, "C", "F")             --> 176.00
MsgBox, % convTemp(212, "K", "Ra", 2)        --> 381.60
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
Sjc1000
Posts: 39
Joined: 02 Oct 2013, 02:07

Re: Convert Temperature

25 Apr 2014, 22:13

Nice job!
I haven't even heard of some of those o.O
Please find me on the IRC if you have any questions, I'm never on the forum anymore.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: kaka2 and 167 guests