Control string representation of infinity.

This commit is contained in:
Bob Nystrom
2015-03-13 07:35:10 -07:00
parent 3ac7d80af5
commit 69567c5eb5
2 changed files with 6 additions and 4 deletions
+2
View File
@@ -960,6 +960,8 @@ DEF_PRIMITIVE(num_toString)
// different outputs (some will format it signed and some won't). To get
// reliable output, handle that ourselves.
if (value != value) RETURN_VAL(wrenNewString(vm, "nan", 3));
if (value == INFINITY) RETURN_VAL(wrenNewString(vm, "infinity", 8));
if (value == -INFINITY) RETURN_VAL(wrenNewString(vm, "-infinity", 9));
// This is large enough to hold any double converted to a string using
// "%.14g". Example: