Tag Archive for 'Fahrenheit'

Convert Celsius to Fahrenheit Online

Since I’ve been having lots of visits in my wxWidgets version of the Celsius to Fahrenheit converter, I’ve decided to prepare an online javascript version which lets you easily make the conversion.

Celsius:
Fahrenheit:



GNU GPL v3 Convert Celsius to Fahrenheit Online is licensed under the GNU GPL v3

Here is the complete source code:

<script type="text/javascript">
// *****************************************************************************
// Description: Convert Celsius to Fahrenheit Online by NeoEGM
// Author: Ezequiel Miravalles
// Last modification: 16/08/2009
// URL: http://www.neoegm.com/tech/online-tools/convert-celsius-to-fahrenheit-online/
// *****************************************************************************

/*******************************************************************************
	Copyright (C) 2009 Ezequiel Gastón Miravalles

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/

function isNumber(x)
{ 
  return ( (typeof x === typeof 1) && (null !== x) && isFinite(x) );	//From http://snippets.dzone.com/posts/show/6937
}

function Round(number, digits)
{
	return Math.round(number * Math.pow(10,digits)) / Math.pow(10, digits);
}

function CelsiusToFahrenheit(celsius, fahrenheit)
{
	var num = celsius.value;
	
	if (num == "" || !isNumber(Number(num)))
		alert("Please type a number");
	else
		fahrenheit.value=Round((9/5)*num+32, 2);
}

function FahrenheitToCelsius(fahrenheit, celsius)
{
	var num = fahrenheit.value;
	
	if (num == "" || !isNumber(Number(num)))
		alert("Please type a number");
	else
		celsius.value=Round((5/9)*(num-32), 2);
}
</script>

<table>
<tr>
<td>Celsius:</td>
<td><input type="text" name="celsius_field" id="celsius_field" style="width:100px" /></td>
<td><input type="button" value="To Fahrenheit" onclick="CelsiusToFahrenheit($('celsius_field'), $('fahrenheit_field'))" /></td>
</tr>
<tr>
<td>Fahrenheit:</td>
<td><input type="text" name="fahrenheit_field" id="fahrenheit_field" style="width:100px" /></td>
<td><input type="button" value="To Celsius" onclick="FahrenheitToCelsius($('fahrenheit_field'), $('celsius_field'))" /></td>
</tr>
</table>

Incoming search terms for the article:

Celsius to Fahrenheit

If you just want to convert temperatures by using a website, you should visit the online celsius to fahrenheit conversion tool. Otherwise, keep reading…

This is a very tiny and simple application I’ve written to teach the basic usage of wxWidgets as an introduction to GUI (Graphical User Interfaces).

Its purpose is just what it’s name says: converting from celsius degrees to fahrenheit degrees (and sideways).

CelsiusAFahrenheit

Keep reading…

Incoming search terms for the article: