Questions tagged [float]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
2 answers

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
2 votes
1 answer

Parsing float numbers in Phala Fat Contract causes deployment failure

Is it possible to get data with float point numbers from the exchange API in Phala's Fat Contract? I have been trying to parse a json object from this API: {"USD":0.106} However, the price ...
h4x3rotab's user avatar
  • 717
1 vote
1 answer

How to get a percent portion of a balance?

I would like to divide a Balance into two parts. One is 10% of value and another part is 90% of the value. BalanceOf<T> is the Balance of a pallet. type Balance: AtLeast32BitUnsigned ...
Chralt's user avatar
  • 543
0 votes
1 answer

IEEE 754 Floating Point Numbers wasm impelementation

We are looking to enable reproducible floating point operations on chain by implementing the IEEE 754 standard as an on-chain wasm function. As discussed in this stackoverflow post, substrate does not ...
Mathis Wellmann's user avatar
0 votes
0 answers

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