-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
uint256_div produce a uint256 (expected decimal) #717
Comments
Agreed. |
See #716 also. Types co-mingling is the root of all chaos. Also, on Ethereum, you usually only ever use integers. Ever. Having decimal as an option is cool, but it's a 1% vs 99% thing. I think dividing ints should give an int. For decimal division, divide decimals. In fact, Vyper should have absolutely no implicit conversions at all (especially not between signed and unsigned ints!) Operations should be allowed between variables of the exact same type, and the result should be the same type as the operands. decimal / decimal = decimal (decimal division) |
@daniel-jozsef the main reason we currently do integer / integer = decimal derision is make the rounding specific by using ceil and floor, making it clear what rounding is being used. |
Integer division is grade school stuff. It's NOT ROUNDING. How many times can you fit two in five? Two times, with a remainder of one. I think it's a horrible antipattern to mix types like this. If we prioritize readability, this is not intuitive at all. Anyone with any experience in programming will expect an operation on two variables of the same type have the exact same type as the two inputs. (Also, using anything other than integers on the blockchain makes me cringe.) If someone wants decimal division between two integers, they should cast them both to decimal. |
@daniel-jozsef @yzhang90 @fubuloubu I agree with your suggestion/assesment and I think we should try and wrap the whole division issue into one clean VIP. I was just giving some background on the the thought process at the time. These are all the related issues I could track: #717 (this one) |
@jacqueswww on board! |
When dividing ints in Vyper it should give a decimal.
When dividing a
uint256
usinguint256_div(x, y)
it produces auint256
instead of adecimal
.I think this should be changed as it is not the expected behaviour.
Cute Animal Picture
The text was updated successfully, but these errors were encountered: