larsiusprime February 2016

Parsing a string representation of a uint64 to a haxe.Int64

I have a a string representation of a big integer, in this case "1083715881696", which I would like to place in a numeric variable.

If I do:

var int:Int = Std.parseInt("1083715881696");

It fails, and I get the result 2147483647 which is 0x7FFFFFFF in hex.

I'd like something like a Std.parseInt64 function, basically -- what's the logical equivalent? I assume the type I'm going to want to store it in here is haxe.Int64, as well.

Answers


Franco Ponticelli February 2016

Next version of Haxe will have such helper: https://github.com/HaxeFoundation/haxe/blob/development/std/haxe/Int64Helper.hx#L30

If you want to use it today you can use thx.core: http://thx-lib.org/api/thx/Int64s.html

If your big-integers are really big you can also use: http://thx-lib.org/api/thx/BigInt.html

Post Status

Asked in February 2016
Viewed 3,828 times
Voted 8
Answered 1 times

Search




Leave an answer