[swift-evolution] Proposal: Remove % operator for floating-point types
ccruden at novafore.com
Fri Dec 18 16:59:19 CST 2015
I am not a numerics expert…… just have run into people using floats in banking and brokerage systems to do calculation with decimal numbers too many times in my life…. I even spent a whole night in a bank vault with the system on conversion trying to figure out why it was out by a single penny :o
If I were not mentally unstable beforehand I would have gone insane over the misuse of floats, and the lack of languages having good decimal numeric types :p
> On 2015-12-19, at 5:47:58, Dave Abrahams <dabrahams at apple.com> wrote:
>> On Dec 18, 2015, at 1:19 PM, Craig Cruden via swift-evolution <swift-evolution at swift.org <mailto: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...
More information about the swift-evolution