Questions tagged [float]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
2 answers
401 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
2 votes
1 answer
131 views

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
235 views

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
46 views

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
66 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