Category talk:Wren-long: Difference between revisions
Content added Content deleted
(→Source code: Bug fix.) |
(→Source code: Constructors no longer permitted to return values so changed to static methods instead.) |
||
Line 214: | Line 214: | ||
} |
} |
||
// Private |
// Private method which creates a ULong object from a Num. |
||
// If 'v' is not small, will probably lose accuracy. |
// If 'v' is not small, will probably lose accuracy. |
||
static fromNum_(v) { |
|||
if (v < 0 || v.isNan) return ULong.zero |
if (v < 0 || v.isNan) return ULong.zero |
||
var m = 4294967296 // 2 ^ 32 |
var m = 4294967296 // 2 ^ 32 |
||
Line 223: | Line 223: | ||
} |
} |
||
// Private |
// Private method which creates a ULong object from a base 10 numeric string. |
||
// Scientific notation is permitted. |
// Scientific notation is permitted. |
||
// Raises an error if the result is out of bounds. |
// Raises an error if the result is out of bounds. |
||
static fromString_(v) { |
|||
v = v.trim() |
v = v.trim() |
||
if (v.count == 0 || v[0] == "-") Fiber.abort("Invalid unsigned integer.") |
if (v.count == 0 || v[0] == "-") Fiber.abort("Invalid unsigned integer.") |
||
Line 284: | Line 284: | ||
// Scientific notation is not permitted. |
// Scientific notation is not permitted. |
||
// Wraps out of range values. |
// Wraps out of range values. |
||
static fromBaseString(v, base) { |
|||
if (!(v is String)) Fiber.abort("Value must be a numeric string in the given base.") |
if (!(v is String)) Fiber.abort("Value must be a numeric string in the given base.") |
||
if (!((base is Num) && base.isInteger && base >= 2 && base <= 36)) { |
if (!((base is Num) && base.isInteger && base >= 2 && base <= 36)) { |