Despite what the ddoc of BigInt.toInt() says, it returns a long. I suggest to change toInt() to really return an int: /// Returns the value of this BigInt as a long, /// or +- long.max if outside the representable range. long toLong() pure const { return (sign ? -1 : 1) * (data.ulongLength() == 1 && (data.peekUlong(0) <= cast(ulong)(long.max)) ? cast(long)(data.peekUlong(0)) : long.max); } /// Returns the value of this BigInt as an int, /// or +- int.max if outside the representable range. long toInt() pure const { return (sign ? -1 : 1) * (data.uintLength() == 1 && (data.peekUint(0) <= cast(uint)(int.max)) ? cast(int)(data.peekUint(0)) : int.max); }
https://github.com/D-Programming-Language/phobos/pull/358
Fixed some time ago. https://github.com/D-Programming-Language/phobos/commit/d619dd513f2f5f7ab2639c34118f03c1672f4485