CopyPastor

Detecting plagiarism made easy.

Score: 0.8364635631985908; Reported for: String similarity Open both answers

Possible Plagiarism

Reposted on 2022-08-25
by K Gunjan

Original Post

Original - Posted on 2022-08-25
by K Gunjan



            
Present in both answers; Present only in the new answer; Present only in the old answer;

here are few examples which should help in conversion of number of type u128 to Balance Type:
//declare following import use frame_support::sp_runtime::SaturatedConversion;
//then saturated_into can be used to convert number into Balance type as follows let cost_in_u128: u128 = 250; //or expression like 200 + 50; let cost: BalanceOf<T> = cost_in_u128.saturated_into::<BalanceOf<T>>(); //convert 1010 of type u32 into Balance let cost2: BalanceOf<T> = 1010u32.into(); //set zero balance let cost3 = BalanceOf::<T>::zero();
where BalanceOf is defined in cfg as follows
#[cfg(feature = "std")] type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
here are few examples which should help in conversion of number to Balance Type:
//declare following import use frame_support::sp_runtime::traits::Zero; use frame_support::sp_runtime::SaturatedConversion;
//then saturated_into can be used to convert number into Balance type as follows let cost_in_u64: u64 = 250; //or expression like 200 + 50; let cost: BalanceOf<T> = cost_in_u64.saturated_into::<BalanceOf<T>>(); //convert 1010 of type u32 into Balance let cost2: BalanceOf<T> = 1010u32.into(); //set zero balance let cost3 = BalanceOf::<T>::zero();
where BalanceOf<T> is defined in cfg as follows
#[cfg(feature = "std")] type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;


        
Present in both answers; Present only in the new answer; Present only in the old answer;