Hot answers tagged

11 votes
Accepted

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

If you are just after the integer sqrt (which, depending on your use-case, may be enough), you could follow the approach that the democracy pallet does. In this case it uses integer_sqrt::...
Jaco's user avatar
  • 5,865
8 votes

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

TLDR: sp-arithmetic for relatively simple use cases as highlighted in this answer, and substrate-fixed for more advance stuff. To perform non-deterministic arithmetic like division and square roots, ...
islami00's user avatar
  • 561
2 votes

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

I think you are in the wrong Stack Exchange :) But I don't think it's possible for anyone to answer without knowing the data source, e.g. is it a lateral inertial sensor that senses side-to-side ...
joepetrowski's user avatar
  • 2,945
2 votes
Accepted

Facing difficulty in fetching data through lite_json

You can do this: let (_, price_no) = list.into_iter().find(|(k, _)| k.iter().copied().eq("price".chars()))?; let p = match price_no { JsonValue::Number(list) =>...
Deepak Chaudhary's user avatar
1 vote

How to use FixedU128?

Note that FixedU128 is not a floating point type. It represents floating point numbers using u128 type with 18 digits of precision. This means that the last 18 digits of any number are taken to be the ...
Sachin's user avatar
  • 61

Only top scored, non community-wiki answers of a minimum length are eligible