Skip to main content

Questions tagged [fixed-point-math]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
71 views

How can I calculate natural log of a number?

Floating-point arithmetic are not allowed in substrate runtime. f64 has an pub fn ln(self) -> f64 to calculate natural log. How can I do that in substrate without using floating points.
Amiya Behera's user avatar
6 votes
1 answer
70 views

from_float function or associated item not found in `FixedU128`

I'm trying to use fixed point variable in my substrate pallet. Here's my import: use frame_support::sp_runtime::FixedU128; and when I try to do this let some_var = FixedU128::from_float(0.1515151f64);...
Ilya Tegmark's user avatar
4 votes
2 answers
412 views

Can you use floating point numbers or math in the Runtime?

I would like to do some basic operations in the runtime like: let new_balance = .5 * old_balance; Or save a percentage value in the runtime storage. Or represent the balance of a user like: 3.141592 ...
Shawn Tabrizi's user avatar
  • 16k
6 votes
3 answers
503 views

What is Perbill and where should it be used?

Often times you'll see Perbill used throughout substrate. It stands for Parts per billion, and here's an example of it being used: parameter_types! { pub const DisabledValidatorsThreshold: Perbill ...
Purple_Turtle's user avatar