• Yorick Peterse's avatar
    Arbitrary precision integer support · c17b6926
    Yorick Peterse authored
    This adds support for arbitrary precision integers using the num-bigint
    crate. Regular integers overflow automatically into either a heap
    allocated i64 or a BigInt, depending on the size of the number.
    
    The code is a bit icky as it relies quite heavily on macros to reduce
    the number of functions necessary to make all this work. Bit shifting
    does use a few functions as they need to call each other recursively,
    something Rust macros can't do (as far as I could figure out at least).
    
    == num-bigint vs rug
    
    We're using num-bigint because it's easier to distribute, has a more
    pleasant API (compared to the "rug" crate) and has a permissive license.
    Performance might be worse compared to rug/GMP, but for the time being
    this should not pose any issues.
    
    == Bitwise operations
    
    Bitwise operations on big integers are currently not yet supported as
    num-bigint does not support these operators on the BigInt type. Once
    https://github.com/rust-num/num-bigint/issues/13 has been solved we can
    add support for these operations.
    c17b6926
serializer.rb 2.96 KB