Questions tagged [math]

For math questions in general that do not fall into special categories such as `floating-point` , `fixed-point`, or `safe-math` as previously used, all of which are also valid subsets of this category hence this tag can also be used to earmark such questions.

Filter by
Sorted by
Tagged with
3 votes
1 answer

Division operation in `u128` results false value

In my node, Balance type is u128. I have following variable let per_block = 100_000_000_000_000_000_u128; let total = 50_000_000_000_000_000_000_000_u128; let ratio = per_block.checked_div(total); ...
4 votes
1 answer

Facing difficulty in fetching data through lite_json

Api data { "student": [ { "listing": { "price": 54, }, }, ] } I’m using below code for fetching data till listing: let student = match val....
3 votes
1 answer

How to use FixedU128?

I'm fetching floating value in offchain worker though lite-json. Json data: { "price": 0.5 } Here is the implementation to fetch the price: let price_str = match obj.clone() { ...
0 votes
1 answer

How do I best calculate angle differences when crossing the 360 axis? (Python) [closed]

I am trying to calculate the total number of turns of a vehicle over time to be a feature in the prediction of accident likelihood. Unfortunately, I am having issues solving the problem of crossing ...
11 votes
2 answers

What's the best way to compute square root in Substrate?

I'm working on a quadratic voting function, and I'm trying to use a function like square root. There is no square root function in sp that I could find. What is the best way to do this?