Browse Source

Numeric ToString/Parse fixes

Brian Fiete 3 years ago
parent
commit
9ca48c26f2

+ 4 - 0
BeefLibs/corlib/src/Int32.bf

@@ -174,6 +174,10 @@ namespace System
 				{
 					// Ignore
 				}
+				else if ((c == '+') && (i == 0))
+				{
+					// Ignore
+				}
 				else
 					return .Err(.InvalidChar(result));
 			}

+ 4 - 0
BeefLibs/corlib/src/Int64.bf

@@ -151,6 +151,10 @@ namespace System
 				{
 					// Ignore
 				}
+				else if ((c == '+') && (i == 0))
+				{
+					// Ignore
+				}
 				else
 					return .Err(.InvalidChar(result));
 			}

+ 5 - 0
BeefLibs/corlib/src/Random.bf

@@ -159,6 +159,11 @@ namespace System
 			return (int64)(((uint64)InternalSample() << 32) | (uint64)InternalSample());
 		}
 
+		public virtual uint64 NextU64()
+		{
+			return (((uint64)InternalSample() << 32) | (uint64)InternalSample());
+		}
+
 		private double GetSampleForLargeRange()
 		{
           // The distribution of double value returned by Sample 

+ 30 - 0
BeefRT/rt/Internal.cpp

@@ -959,6 +959,21 @@ static int ToString(float d, char* outStr)
 			}
 		}
 	}
+	if ((len == 3) && (outStr[0] == 'i'))
+	{
+		strcpy(outStr, "Infinity");
+		return 8;
+	}
+	if ((len == 4) && (outStr[0] == '-') && (outStr[1] == 'i'))
+	{
+		strcpy(outStr, "-Infinity");
+		return 9;
+	}
+	if ((len == 9) && (outStr[0] == '-') && (outStr[1] == 'n')) //-nan(xxx)
+	{
+		strcpy(outStr, "NaN");
+		return 3;
+	}
 	return len;
 }
 
@@ -993,6 +1008,21 @@ static int ToString(double d, char* outStr)
 			}
 		}
 	}
+	if ((len == 3) && (outStr[0] == 'i'))
+	{
+		strcpy(outStr, "Infinity");
+		return 8;
+	}
+	if ((len == 4) && (outStr[0] == '-') && (outStr[1] == 'i'))
+	{
+		strcpy(outStr, "-Infinity");
+		return 9;
+	}
+	if ((len == 9) && (outStr[0] == '-') && (outStr[1] == 'n')) //-nan(xxx)
+	{
+		strcpy(outStr, "NaN");
+		return 3;
+	}
 	return len;
 }