pub fn format_int_exp(num: I256) -> String
Expand description
Formats a U256 number to string, adding an exponential notation hint.
Same as format_uint_exp
.
ยงExamples
use alloy_primitives::I256;
use foundry_common_fmt::format_int_exp as f;
assert_eq!(f(I256::try_from(0).unwrap()), "0");
assert_eq!(f(I256::try_from(-1).unwrap()), "-1");
assert_eq!(f(I256::try_from(1234).unwrap()), "1234");
assert_eq!(f(I256::try_from(1234567890).unwrap()), "1234567890 [1.234e9]");
assert_eq!(f(I256::try_from(-1234567890).unwrap()), "-1234567890 [-1.234e9]");
assert_eq!(f(I256::try_from(1000000000000000000_u128).unwrap()), "1000000000000000000 [1e18]");
assert_eq!(
f(I256::try_from(10000000000000000000000_u128).unwrap()),
"10000000000000000000000 [1e22]"
);
assert_eq!(
f(I256::try_from(-10000000000000000000000_i128).unwrap()),
"-10000000000000000000000 [-1e22]"
);