temperature converter identifier

By PuNkTuReD on Jan 28, 2009

Usage:
$temp(,<c|f|k|ran|rea>).<c|f|k|ran|rea>

About:
$temp(100,c).f
will convert 100 degrees celcius into fahrenheit
$temp(100,f).c
will convert 100 degrees fahrenheit into celcius

k = Kelvin
c = Celcius
f = Fahrenheit
ran = Rankine
rea = Reaumur

example:
//msg $chan its about $temp(40,c).f
[13:29] <~Rage_Virus> its about 104 degrees Fahrenheit

this code is to be put in your "aliases" tab

;  $temp(<temperature>,<c|f|k|ran|rea>).<c|f|k|ran|rea>

/temp {
  ; Fahrenheit to Celcius/Kelvin/Rankine/Réaumur
  if ($2 == f) {
    if ($prop == c) { return $calc($calc($($1) - 32) * 5/9) degrees Celcius }
    elseif ($prop == k) { return $calc(5/9 * $calc($1 - 32) + 273.15) degrees Kelvin }
    elseif ($prop == ran) { return $calc($1 + 459.67) degrees Rankine }
    elseif ($prop == rea) { return $calc($calc($1 - 32) / 2.25) degrees Réaumur }
  }
  : Celcius to Fahrenheit/Kelvin/Rankine/Réaumur
  elseif ($2 == c) {
    if ($prop == f) { return $calc($calc($1 * 9/5) + 32) degrees Fahrenheit }
    elseif ($prop == k) { return $calc($1 + 273.15) degrees Kelvin }
    elseif ($prop == ran) { return $calc($calc($1 + 273.15) * 9/5) degrees Rankine }
    elseif ($prop == rea) { return  $calc($1 * 0.8) degrees Réaumur }
  }
  : Kelvin to Celcius/Fahrenheit/Rankine/Réaumur
  elseif ($2 == k) {
    if ($prop == c) { return $calc($1 - 273.15) degrees Celcius }
    elseif ($prop == f) { return $calc($calc($1  * 9/5) - 459.67) degrees Fahrenheit }
    elseif ($prop == ran) { return $calc($1 * 9/5) degrees Rankine }
    elseif ($prop == rea) { return $calc($calc($1 - 273.15) * 0.8) degrees Réaumur }
  }
  ; Rankine to Celcius/Fahrenheit/Kelvin/Réaumur
  elseif ($2 == ran) {
    if ($prop == c) { return  $calc($calc($calc($1 - 32) - 459.67) / 9/5) degrees Celcius }
    elseif ($prop == f) { return $calc($1 - 459.67) degrees Fahrenheit }
    elseif ($prop == k) { return $calc($1 / 9/5) degrees Kelvin }
    elseif ($prop == rea) { return $calc($calc($1 - 32 - 459.67) / 9/4) degrees Réaumur }
  }
  ; Réaumur to Celcius/Fahrenheit/Kelvin/Rankine
  elseif ($2 == rea) {
    if ($prop == c) { return $calc($1 * 10/8) degrees Celcius }
    elseif ($prop == f) { return $calc($calc($1 * 9/4) + 32) degrees Fahrenheit }
    elseif ($prop == k) { return $calc($calc($1 * 10/8) + 273.15) degrees Kelvin }
    elseif ($prop == ran) { return $calc($1 * 2.24) degrees Rankine }
  }
}

Comments

Sign in to comment.
Aucun50   -  Jan 29, 2009

WOW! Nice 8/10 cus i like to see the temperature in different ways :)

 Respond  
PuNkTuReD   -  Jan 28, 2009

lol
@napa im working on it but im havin a bit of difficulties
@Thelmrac ok ok im onto it

edited to include
Kelvin, Rankine, and Réaumur

 Respond  
TheImrac   -  Jan 28, 2009
alias temp {
  If ($2 == f) return $calc(($1 - 32) * 5/9) degrees Celcius
  ElseIf ($2 == c) return $calc($1 * 9/5 + 32) degrees Fahrenheit 
}
 Respond  
napa182   -  Jan 28, 2009

put it in aliases and do //echo -a $temp( , <c|f> )

ffs read the intro

 Respond  
Aucun50   -  Jan 28, 2009

How do i use? TEMP Unknown command

 Respond  
napa182   -  Jan 28, 2009

what about Kelvin, Rankine, and Réaumur?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.