Convert Temperature

Post your working scripts, libraries and tools
User avatar
jNizM
Posts: 2583
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
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] 1.1.30.03 x64 Unicode | [WIN] 10 Pro (Version 1909) x64 | [GitHub] Profile
Donations are appreciated if I could help you
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”

Who is online

Users browsing this forum: No registered users and 132 guests