Macro soroban_sdk::bigint
source · [−]macro_rules! bigint {
($env:expr $(,)?) => { ... };
($env:expr, [$($x:expr),+ $(,)?] $(,)?) => { ... };
($env:expr, $x:tt $(,)?) => { ... };
($env:expr, -$x:tt $(,)?) => { ... };
}
Expand description
Create a BigInt with an integer, hex, bits, or an array.
The first argument in the list must be a reference to an Env.
The second argument can be an integer literal of unbounded size in any form: base10, hex, etc, or an u8 array.
Examples
Create a BigInt with an integer:
use soroban_sdk::{Env, bigint};
let env = Env::default();
let big = bigint!(&env, -5);
assert_eq!(big.to_i64(), -5i64);
Create a BigInt with hex:
use soroban_sdk::{Env, bigint};
let env = Env::default();
let big = bigint!(&env, 0xfded3f55dec47250a52a8c0bb7038e72fa6ffaae33562f77cd2b629ef7fd424d);
assert_eq!(big.bits(), 256);
Create a BigInt with an array:
use soroban_sdk::{Env, bigint};
let env = Env::default();
let big = bigint!(&env, [2, 0]);
assert_eq!(big, 512);