Permalink
Browse files

Fixed issue where evaluating tagged bools always returned NaN.

  • Loading branch information...
1 parent 7b8fd39 commit 161945d28f0e396d11d3687251511a2130ddf1a4 @otac0n otac0n committed Jul 9, 2011
Showing with 12 additions and 2 deletions.
  1. +10 −0 Src/IronJS.Runtime/TaggedBools.cs
  2. +2 −2 Src/IronJS.Runtime/TypeConverter.cs
View
10 Src/IronJS.Runtime/TaggedBools.cs
@@ -17,5 +17,15 @@ public static double ToTagged(bool value)
{
return value ? True : False;
}
+
+ internal static bool IsTrue(double d)
+ {
+ return double.IsNaN(d) && (BitConverter.DoubleToInt64Bits(d) == TrueBitPattern);
+ }
+
+ internal static bool IsFalse(double d)
+ {
+ return double.IsNaN(d) && (BitConverter.DoubleToInt64Bits(d) == TrueBitPattern);
+ }
}
}
View
4 Src/IronJS.Runtime/TypeConverter.cs
@@ -509,12 +509,12 @@ public static double ToNumber(string s)
public static double ToNumber(double d)
{
- if (double.IsNaN(d) && (TaggedBools.True == BitConverter.DoubleToInt64Bits(d)))
+ if (TaggedBools.IsTrue(d))
{
return 1.0;
}
- if (double.IsNaN(d) && (TaggedBools.False == BitConverter.DoubleToInt64Bits(d)))
+ if (TaggedBools.IsFalse(d))
{
return 0.0;
}

0 comments on commit 161945d

Please sign in to comment.