[swift-evolution] Proposal: Remove % operator for floating-point types

Dave Abrahams dabrahams at apple.com
Fri Dec 18 16:47:58 CST 2015

> On Dec 18, 2015, at 1:19 PM, Craig Cruden via swift-evolution <swift-evolution at swift.org> wrote:
> http://www.exploringbinary.com/why-0-point-1-does-not-exist-in-floating-point/ <http://www.exploringbinary.com/why-0-point-1-does-not-exist-in-floating-point/>
>> On 2015-12-19, at 4:17:45, Craig Cruden <ccruden at novafore.com <mailto:ccruden at novafore.com>> wrote:
>> Floating point numbers by their very nature are approximation represented in binary.  Many numbers in Decimal cannot be represented exactly in decimal floating point format.  
>> So after math calculations decimal number -> floating point binary -> repeating decimal numbers.
>> If decimal accuracy such as accounting, you should avoid using floats altogether and stick to Decimal type numbers (in java it is called BigDecimal, in Swift they have NSDecimalNumber I think which has it’s own issues.

Just for background and to save time, I’ll note out that Steve is one of Apple’s most respected numerics experts, and he’s more familiar with the details of how floating point, decimal, and other numeric representations work than just about anyone I’ve ever met.

FWIW-ly y’rs,


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/10cb13af/attachment.html>

More information about the swift-evolution mailing list