Crates.io | solana-safe-math |
lib.rs | solana-safe-math |
version | 0.1.0 |
source | src |
created_at | 2022-01-31 13:57:41.5164 |
updated_at | 2022-01-31 13:57:41.5164 |
description | Safe Math wrapper for the primitive numberic types used in a Solana program |
homepage | https://github.com/Apocentre/solana-safe-math |
repository | https://github.com/Apocentre/solana-safe-math |
max_upload_size | |
id | 524589 |
size | 6,326 |
use solana_safe_math::{SafeMath};
fn process_init_escrow(
accounts: &[AccountInfo],
amount: u64,
program_id: &Pubkey
) -> ProgramResult {
let val = 10_u64;
val.safe_add(amount)?;
val.safe_sub(amount)?;
val.safe_mul(amount)?;
val.safe_div(amount)?;
val.safe_pow(8_u32)?;
}
Works with u128
, u64
, u32
, u16
and u8