[swift-evolution] Is there a need for a Decimal type?

Jonathan Tang jonathan.d.tang at gmail.com
Sat Feb 13 12:55:42 CST 2016


General +1, but I'm wondering if a better development process would be to
release this as an open-source library, get some adoption, respond to
user-feedback, and then propose to integrate that library into the stdlib.
You can iterate much faster in a library than in the language standard, and
APIs usually end up being a lot cleaner when designed in response to user
feedback than when designed by committee.  (Particularly when the library
in question is fairly domain-specific.)

On Sat, Feb 13, 2016 at 4:03 AM, Craig Cruden via swift-evolution <
swift-evolution at swift.org> wrote:

> Big Yes!
>
> Most business applications require the use of Decimal numbers.
> NSDecimalNumber is sludgy to use in Swift and generally does not
> interoperate well - and with limited functionality.
>
> It should be a base type, and the same computational infix operators
> should be able to be used.
>
>
> > On 2016-02-13, at 18:51:39, Dale Buckley via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > We all know the problems with floating point types, they are well
> documented and well understood by developers everywhere. We know when to
> use them and (hopefully) when not to use them and if you are working with
> financial values on a Foundation based platform you know to not use a
> floating point type and to use NSDecimalNumber instead.
> >
> > My question is this; should there be an equivalent NSDecimalNumber type
> built into Swift that can be used for precision sensitive decimal values
> where floating point types can’t be used?
> >
> > Maybe the answer isn’t an ‘equivalent’ as such, it would probably have a
> modern twist so I can see it looking like something else entirely, but the
> point still stands.
> >
> > I feel like there is a need for this, it’s not a new problem and has
> been solved many times over in other languages such as Objective-C
> (NSDecimalNumber) and Java (BigDecimal) etc. Yet as it stands we seem to be
> lacking an equivalent solution in Swift. It shouldn’t be left for an
> external library to solve, it’s one of those things that need to be built
> into the language.
> >
> > What are peoples thoughts on this?
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160213/56d41a76/attachment.html>


More information about the swift-evolution mailing list