solana-safe-math

Crates.iosolana-safe-math
lib.rssolana-safe-math
version0.1.0
sourcesrc
created_at2022-01-31 13:57:41.5164
updated_at2022-01-31 13:57:41.5164
descriptionSafe Math wrapper for the primitive numberic types used in a Solana program
homepagehttps://github.com/Apocentre/solana-safe-math
repositoryhttps://github.com/Apocentre/solana-safe-math
max_upload_size
id524589
size6,326
Pavlos Polianidis (ppoliani)

documentation

https://docs.rs/solana-safe-math/

README

Solana Safe Math

 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

Commit count: 2

cargo fmt