-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Point recipe #196
Fixed Point recipe #196
Conversation
@brenzi Can you help me understand a bit about substrate-fixed? I'm trying to write a recipe about using fixed point math in Substrate, and I saw some postings about the cool transcendental functions in substrate-fixed. Commit 4199e2c has my attempts to use it, but I'm having some trouble. Here are some concrete questions.
let a = U32F32::from_num(1);
// This works
let b = a * 2;
// This doesn't
let c = a * 2u32;
@coriolinus your help is also welcome. I know you recommended substrate-fixed. Not sure whether you've used it though. |
|
This is a stopgap measure to remove broken links. This article has been properly removed in the follow-substrate-master branch, but not merged here yet :-/
Also requesting review from @brenzi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I've found a few typos and quibbles, but in general they should all be very straightforward fixes.
That said, I have not performed an in-depth code review; I take it as given that the example pallets do what they say they will.
Co-Authored-By: Peter Goodspeed-Niklaus <[email protected]>
Co-Authored-By: Peter Goodspeed-Niklaus <[email protected]>
Co-Authored-By: Peter Goodspeed-Niklaus <[email protected]>
Co-Authored-By: Peter Goodspeed-Niklaus <[email protected]>
Co-Authored-By: Peter Goodspeed-Niklaus <[email protected]>
a88f091 just undid a bunch of the fixes in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few typos/nits, but LGTM. I'm a more comma-heavy writer and would use more commas in the text, especially before "which" clauses, but it's fine if you like it.
Co-Authored-By: joe petrowski <[email protected]>
Co-Authored-By: joe petrowski <[email protected]>
Co-Authored-By: joe petrowski <[email protected]>
Co-Authored-By: joe petrowski <[email protected]>
Co-Authored-By: joe petrowski <[email protected]>
Teach users why we don't use floats, and some options for working around them.
Idea: Continuous and discrete compounding interest. Discrete compounding is paid out every ten block in on_finalize and uses Substrate's simple fixed point stuff (specifically Percent). Continuously compounding interest is calculated and paid out when deposits or withdraws are made and use the more advanced exponential features of https://github.com/encointer/substrate-fixed