Error when konverting K/s to °C/s


First of all, excellent work, this library has saved me a lot of times!

I think there is an error when converting K/s to °C/s. Example code :

// Define celsius per second - °C/s
IPhysicalUnit Ce_per_s = SI.Ce.CombineDivide(SI.s);

// Define kelvin per second - K/s
IPhysicalUnit Kelvin_per_s = SI.K.CombineDivide(SI.s);

// Create value in units °C/s
PhysicalQuantity valueOfCelsiusPerSecond = new PhysicalQuantity(2, Ce_per_s);
Console.WriteLine("Base value : {0}", valueOfCelsiusPerSecond); // prints 2 °C/s

// Convert °C/s to K/s
IPhysicalQuantity valueOfKelvinPerSecond = valueOfCelsiusPerSecond.ConvertTo(Kelvin_per_s);
Console.WriteLine("Base value converted to {0} : {1}", Ce_per_s, valueOfKelvinPerSecond);
// prints 275.15 K/s - correct conversion

// Convert K/s back to °C/s
Console.WriteLine("{0} converted back to {1}: {2}", Kelvin_per_s, Ce_per_s, valueOfKelvinPerSecond.ConvertTo(Ce_per_s));
// prints 1.0036476381543 °C/s - should print 2 °C/s - incorrect conversion

Best regards,

Closed Nov 11, 2013 at 1:09 AM by KiloBravo
Added handling of relative and absolute unit conversions for absolute units. Eg. temperatures and temperature intervals.


KiloBravo wrote Sep 7, 2013 at 5:46 PM

Hi Jurica

Yes, You are right, there a problem with scaled units with an offset (different from 0).

I think the problem is already in the conversion from °C/s to K/s. It is right that 2 °C should be converted to 275.15 K, when this is a specific temperature. But if it is a temperature difference, then the 2 °C /s should be converted to 2 K/s !!!

For the moment I have no (simple and easy) way to handle this problem. The current implementation has errors in the conversion of units involving converted units with offsets, because the difference between specific (temperature) values and temperature intervals are not taken in to account.

I hope that I soon will have the time to look into this fundamental problem, but for now you must be very careful when using conversion of units using scaled sub-units.

wrote Nov 11, 2013 at 1:09 AM