MadsKirkFoged/EngineeringUnits

Temperature conversion doesn't work

haikal-arif opened this issue · 4 comments

I am using sharpfluids when i noticed this bug
This is piece of code that i can isolate

static void Main(string[] args)
{
	var temperature = Temperature.FromDegreesCelsius(20);
	var pressure = Pressure.FromKilopascals(100);
	Console.WriteLine("Pressure: {0} \nTemperature: {1}", pressure.ToUnit(EngineeringUnits.Units.PressureUnit.Kilopascal), temperature.ToUnit(EngineeringUnits.Units.TemperatureUnit.DegreeCelsius));
}

Output :
Pressure: 100 kPa
Temperature: 293,2 K

Expected behavior:
Temperature in Celsius

Observed behavior:
Temperature in Kelvin

Thanks you very much for reporting the bug!
Can you update and try again? It should be fixed now

Thanks for the quick response, it's fixed now

just get back to the project and found out that i overlooked the value conversion and too focused in the units

double inputVal = 300.6;
var temperature = new Temperature(inputVal, TemperatureUnit.Kelvin);
var temperatureConvert = temperature.ToUnit(TemperatureUnit.DegreeCelsius).ToString();
var temperatureCelsius = temperature.DegreesCelsius;
Console.WriteLine($"{inputVal} K is {temperatureConvert} or {temperatureCelsius:0.##} °C");

Output:
300,6 K is 0 °C or 27,45 °C

The unit is right but the value isn't consistent

Should be fixed now.
It was a bug I made trying to fix the first bug :-D
Temperature is a bit different then all other units.