forked from TheAlgorithms/JavaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperatureConversion.js
More file actions
Latest commit
113 lines (96 loc) · 3.65 KB
/
Copy pathTemperatureConversion.js
File metadata and controls
113 lines (96 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// This files has functions to convert different temperature units
// Functions take temperature value as a argument and returns corresponding converted value
constcelsiusToFahrenheit=(celsius)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
returnMath.round((celsius*9)/5+32)
}
constcelsiusToKelvin=(celsius)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
returnMath.round(celsius+273.15)
}
constcelsiusToRankine=(celsius)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
returnMath.round((celsius*9)/5+491.67)
}
constfahrenheitToCelsius=(fahrenheit)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
returnMath.round(((fahrenheit-32)*5)/9)
}
constfahrenheitToKelvin=(fahrenheit)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
returnMath.round(((fahrenheit-32)*5)/9+273.15)
}
constfahrenheitToRankine=(fahrenheit)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
returnMath.round(fahrenheit+459.67)
}
constkelvinToCelsius=(kelvin)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
returnMath.round(kelvin-273.15)
}
constkelvinToFahrenheit=(kelvin)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
returnMath.round(((kelvin-273.15)*9)/5+32)
}
constkelvinToRankine=(kelvin)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
returnMath.round((kelvin*9)/5)
}
constrankineToCelsius=(rankine)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
// Wikipedia reference: https://en.wikipedia.org/wiki/Celsius
returnMath.round(((rankine-491.67)*5)/9)
}
constrankineToFahrenheit=(rankine)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
// Wikipedia reference: https://en.wikipedia.org/wiki/Fahrenheit
returnMath.round(rankine-459.67)
}
constrankineToKelvin=(rankine)=>{
// Wikipedia reference: https://en.wikipedia.org/wiki/Rankine_scale
// Wikipedia reference: https://en.wikipedia.org/wiki/Kelvin
returnMath.round((rankine*5)/9)
}
constreaumurToKelvin=(reaumur)=>{
// Reference:- http://www.csgnetwork.com/temp2conv.html
returnMath.round(reaumur*1.25+273.15)
}
constreaumurToFahrenheit=(reaumur)=>{
// Reference:- http://www.csgnetwork.com/temp2conv.html
returnMath.round(reaumur*2.25+32)
}
constreaumurToCelsius=(reaumur)=>{
// Reference:- http://www.csgnetwork.com/temp2conv.html
returnMath.round(reaumur*1.25)
}
constreaumurToRankine=(reaumur)=>{
// Reference:- http://www.csgnetwork.com/temp2conv.html
returnMath.round(reaumur*2.25+32+459.67)
}
export{
celsiusToFahrenheit,
celsiusToKelvin,
celsiusToRankine,
fahrenheitToCelsius,
fahrenheitToKelvin,
fahrenheitToRankine,
kelvinToCelsius,
kelvinToFahrenheit,
kelvinToRankine,
rankineToCelsius,
rankineToFahrenheit,
rankineToKelvin,
reaumurToCelsius,
reaumurToFahrenheit,
reaumurToKelvin,
reaumurToRankine
}