Skip to content
Discussion options

You must be logged in to vote

As per a private chat on Telegram, I was wrong when I said:

Phantom overflow is not an issue with PRBMath

Phantom overflow can be an issue when operating with large values near the maximum uint256 value, e.g.

UD60x18 a = ud(type(uint256)-max / 2) ;
UD60x18 b = ud(type(uint256)-max / 2);
UD60x18 c = ud(type(uint256).max);
a.mul(b).div(c); // will revert even if the `mulDiv` wouldn't.

In light of this, I am now in favor of implementing a mulDiv function that takes only UD60x18 as inputs and outputs.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@ivanvolov
Comment options

@PaulRBerg
Comment options

@PaulRBerg
Comment options

Answer selected by PaulRBerg
Comment options

You must be logged in to vote
0 replies
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