Navigation Menu

Skip to content

Commit

Permalink
Fixed issue where evaluating tagged bools always returned NaN.
Browse files Browse the repository at this point in the history
  • Loading branch information
otac0n committed Jul 9, 2011
1 parent 7b8fd39 commit 161945d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Src/IronJS.Runtime/TaggedBools.cs
Expand Up @@ -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);
}
}
}
4 changes: 2 additions & 2 deletions Src/IronJS.Runtime/TypeConverter.cs
Expand Up @@ -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;
}
Expand Down

0 comments on commit 161945d

Please sign in to comment.