You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The four seed parameters defined for Xoshiro256ss are int each.
However, in dart the int type is only 2^63-1 max value, because 1 bit is used for defining the sign (https://stackoverflow.com/a/53591126/346488).
Which means int is not a proper type to use as an input, as it is not possible to pass each part as a true 64-bit integer.
E.g. I have an issue passing one as: int.parse('f78207dec08eba34', radix:16)
It returns an error: [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Positive input exceeds the limit of integer
It looks like the right approach would be to use BigInt as input parameters type and then check inside that each parameter is within 64 bits.
Could you please check on this?
Thank you!
The text was updated successfully, but these errors were encountered:
Although the positive int values in Dart VM do not exceed 2^63-1, these variables are still true 64-bit integers.
If it were a C language, we would clarify that we are talking about 64-bit signed, not 64-bit unsigned. But these are not two fundamentally different things. In many cases, they are interchangeable and almost identical.
In a particular case, to pass a large unsigned number f78207dec08eba34 as a seed, you just need to use its signed counterpart -87df8213f7145cc. This number will fit into a regular int in Dart.
import'package:fixnum/fixnum.dart';
voidmain() {
// interpreting a large number constant as a regular int (aka 64-bit signed)int seed =Int64.parseHex('f78207dec08eba34').toInt();
...
}
Thanks, I've seen this fixnum library, but didn't realize that it actually can be used to convert to a standard "int" type instead of using their Int64.
It works fine, the issue can be closed.
Thank you for your help!
Hello
The four seed parameters defined for Xoshiro256ss are int each.
However, in dart the int type is only 2^63-1 max value, because 1 bit is used for defining the sign (https://stackoverflow.com/a/53591126/346488).
Which means int is not a proper type to use as an input, as it is not possible to pass each part as a true 64-bit integer.
E.g. I have an issue passing one as:
int.parse('f78207dec08eba34', radix:16)
It returns an error:
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FormatException: Positive input exceeds the limit of integer
It looks like the right approach would be to use BigInt as input parameters type and then check inside that each parameter is within 64 bits.
Could you please check on this?
Thank you!
The text was updated successfully, but these errors were encountered: