Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upDivision and rational numbers #901
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Apr 19, 2017
Member
Under this proposal, division of integers always results in an Integer (or an exception for dividing by zero), based on round-towards-zero semantics. If we add a rational type later, the way to get at rational division would be to cast both arguments to a rational, and then divide.
It's understandable if this behavior and future interface is undesirable. One alternative here would be to throw in this proposal on all division, so that we can make it result in another type to express the exact answer in a future proposal. However, this choice would be an unfortunate missing feature as far as ergonomics, and it would block users who would use Integer to get at many machines' underlying int64 division hardware.
|
Under this proposal, division of integers always results in an Integer (or an exception for dividing by zero), based on round-towards-zero semantics. If we add a rational type later, the way to get at rational division would be to cast both arguments to a rational, and then divide. It's understandable if this behavior and future interface is undesirable. One alternative here would be to throw in this proposal on all division, so that we can make it result in another type to express the exact answer in a future proposal. However, this choice would be an unfortunate missing feature as far as ergonomics, and it would block users who would use Integer to get at many machines' underlying int64 division hardware. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ljharb
Apr 19, 2017
Member
This question belongs in the proposal repo itself, not here on the spec repo.
|
This question belongs in the proposal repo itself, not here on the spec repo. |
cxielarko commentedApr 19, 2017
Are Integers intended to be compatible with a (hypothetical) rational type, and if so, how should division be handled? Under the current definition of division, either integers couldn't be treated as a subset of rationals, or there would need to be a separate operator for rational division.