Skip to content

Contract with Fixed Point and non-Fixed Point ints #43

Closed Answered by PaulRBerg
joaomontenegro asked this question in Q&A
Discussion options

You must be logged in to vote

First way is to use the PRBMathSD59x18Typed.sol and PRBMathUD60x18Typed.sol flavours of PRBMath.

A second way, if you intend to use the vanilla flavours of the library, is to group the fixed-point types within structs, so that I know that if I ever use that struct, all of its containing integers are fixed-point numbers. E.g. here.

A third way, mentioned by @definim in #29, is to use a different nomenclature for the fixed-point variables. E.g. he used Hungarian notation.

Update for PRBMath v3.0.0:

Type safety is now offered via user defined value types SD59x18 and UD60x18. You differentiate fixed-point from non-fixed-point types by simply declaring your variable with the value type (in fac…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@PaulRBerg
Comment options

@joaomontenegro
Comment options

Answer selected by PaulRBerg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants