Bläddra i källkod

* fixed FahrenheitToCelsius() and CelsiusToFahrenheit() (mantis #13133)

git-svn-id: trunk@12721 -
Jonas Maebe 16 år sedan
förälder
incheckning
053493fbeb
3 ändrade filer med 15 tillägg och 2 borttagningar
  1. 1 0
      .gitattributes
  2. 2 2
      rtl/objpas/stdconvs.pp
  3. 12 0
      tests/webtbs/tw13133.pp

+ 1 - 0
.gitattributes

@@ -8749,6 +8749,7 @@ tests/webtbs/tw1295.pp svneol=native#text/plain
 tests/webtbs/tw1299.pp svneol=native#text/plain
 tests/webtbs/tw13019.pp svneol=native#text/plain
 tests/webtbs/tw1310.pp svneol=native#text/plain
+tests/webtbs/tw13133.pp svneol=native#text/plain
 tests/webtbs/tw1318.pp svneol=native#text/plain
 tests/webtbs/tw1323.pp svneol=native#text/plain
 tests/webtbs/tw1327.pp svneol=native#text/plain

+ 2 - 2
rtl/objpas/stdconvs.pp

@@ -199,12 +199,12 @@ implementation
 
 function FahrenheitToCelsius(const AValue: Double): Double;
 begin
-  result:= 32.0 + ((9.0 * AValue)/ 5.0);
+  result:= (5.0/9.0)  * (Avalue - 32.0);
 end;
 
 function CelsiusToFahrenheit(const AValue: Double): Double;
 begin
-  result:= (5.0/9.0)  * (Avalue - 32.0);
+  result:= 32.0 + ((9.0 * AValue)/ 5.0);
 end;
 
 function CelsiusToKelvin    (const AValue: Double): Double;

+ 12 - 0
tests/webtbs/tw13133.pp

@@ -0,0 +1,12 @@
+uses
+  stdconvs,math;
+begin
+  if CompareValue(FahrenheitToCelsius(32.0),0.0,0.000000001)<>EqualsValue then
+    halt(1);
+  if CompareValue(FahrenheitToCelsius(89.6),32.0,0.000000001)<>EqualsValue then
+    halt(2);
+  if CompareValue(CelsiusToFahrenheit(32.0),89.6,0.000000001)<>EqualsValue then
+    halt(3);
+  if CompareValue(CelsiusToFahrenheit(0.0),32.0,0.000000001)<>EqualsValue then
+    halt(4);
+end.