Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-24 Thread Rainer Brockerhoff via swift-evolution
(replying on gmane as I see my previous reply lost threading. @#$%^ Thunderbird.) On 3/24/16 11:31, Stephen Canon via swift-evolution wrote: >> On Mar 24, 2016, at 10:01 AM, Rainer Brockerhoff >> wrote: >> >> There's the mismatch between decimal representation of binary formats, >> causing confu

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-24 Thread Stephen Canon via swift-evolution
> On Mar 24, 2016, at 10:01 AM, Rainer Brockerhoff > wrote: > > There's the mismatch between decimal representation of binary formats, > causing confusion for very common cases like 0.01. There's your work in > upgrading the FloatingPoint protocol. There's the question of > modernizing NSDecimal

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-24 Thread Rainer Brockerhoff via swift-evolution
On 3/24/16 09:54, Stephen Canon wrote: > On Mar 23, 2016, at 5:26 AM, Rainer Brockerhoff via swift-evolution > wrote: ... >> On 3/22/16 23:20, Michael Gottesman via swift-evolution wrote: Pre-proposal: Safer Decimal Calculations Proposal: TBD Author(s): Rainer Brockerhoff Status: TBD R

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-24 Thread Stephen Canon via swift-evolution
On Mar 23, 2016, at 5:26 AM, Rainer Brockerhoff via swift-evolution wrote: > On 3/22/16 23:20, Michael Gottesman via swift-evolution wrote: >> >>> On Mar 18, 2016, at 3:42 PM, Rainer Brockerhoff via swift-evolution >>> wrote: >>> >>> First draft towards a tentative pre-proposal: >>> https://

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-23 Thread Michael Gottesman via swift-evolution
> On Mar 23, 2016, at 5:26 AM, Rainer Brockerhoff via swift-evolution > wrote: > > On 3/22/16 23:20, Michael Gottesman via swift-evolution wrote: >> >>> On Mar 18, 2016, at 3:42 PM, Rainer Brockerhoff via swift-evolution >>> wrote: >>> >>> First draft towards a tentative pre-proposal: >>> h

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-23 Thread Rainer Brockerhoff via swift-evolution
On 3/22/16 23:20, Michael Gottesman via swift-evolution wrote: > >> On Mar 18, 2016, at 3:42 PM, Rainer Brockerhoff via swift-evolution >> wrote: >> >> First draft towards a tentative pre-proposal: >> https://gist.github.com/rbrockerhoff/6874a5698bb479886e83 >> -- >> >> Pre-proposal: Safer D

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-22 Thread Michael Gottesman via swift-evolution
> On Mar 18, 2016, at 3:42 PM, Rainer Brockerhoff via swift-evolution > wrote: > > First draft towards a tentative pre-proposal: > https://gist.github.com/rbrockerhoff/6874a5698bb479886e83 > -- > > Pre-proposal: Safer Decimal Calculations > Proposal: TBD > Author(s): Rainer Brockerhoff > S

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-21 Thread Harlan Haskins via swift-evolution
I still absolutely think the best proposal for this is to add a Fraction type to the standard library with easy conversions to and from all the numeric types. Your precision is only limited by the size of IntMax, and you can do whatever operations you want without losing precision. There’s a gre

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-21 Thread Haravikk via swift-evolution
> On 20 Mar 2016, at 17:54, Rainer Brockerhoff via swift-evolution > wrote: > > On 3/20/16 14:43, Andrey Tarantsov via swift-evolution wrote: >> I have no stake in this proposal, except for: >> >>> I suggest, therefore, that this acceptance be indicated by an >>> annotation to the literal; a f

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-20 Thread Rainer Brockerhoff via swift-evolution
On 3/20/16 14:43, Andrey Tarantsov via swift-evolution wrote: > I have no stake in this proposal, except for: > >> I suggest, therefore, that this acceptance be indicated by an >> annotation to the literal; a form such as ~0.1 might be easiest to >> read and implement, as the prefix ~ operator cu

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-20 Thread Andrey Tarantsov via swift-evolution
I have no stake in this proposal, except for: > I suggest, therefore, that this acceptance be indicated by > an annotation to the literal; a form such as ~0.1 might be easiest to > read and implement, as the prefix ~ operator currently has no meaning > for a floating-point value. Whatever you do,

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-20 Thread Step Christopher via swift-evolution
Ah, thanks. No surprises there. I use a similar approach and it is often sufficient. `newtype` could reduce boilerplate there but not necessarily by a lot. Do you think that kind of "wrapper-type" replacement is the right place to target first? > El mar 20, 2016, a las 10:32 AM, Tino Heth <2..

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-20 Thread Tino Heth via swift-evolution
> Do you have a link to that research? I'd be very interested. no raw data ;-) — but I tend to believe what has been written here (and in the discussion afterwards): http://article.gmane.org/gmane.comp.lang.swift.evolution/1300 Ti

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-19 Thread Step C via swift-evolution
Do you have a link to that research? I'd be very interested. > On Mar 19, 2016, at 11:46 AM, Tino Heth via swift-evolution > wrote: > > >> Can't quite see where "Inheritance for structs / "newtype"-feature" >> enables this, however. Care to explain? > It's not required, but unless you want to

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-19 Thread Tino Heth via swift-evolution
> Can't quite see where "Inheritance for structs / "newtype"-feature" > enables this, however. Care to explain? It's not required, but unless you want to implement a completely new numeric type (like fractions), it is tedious to declare all operations and conversions that are useful or required:

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-19 Thread Rainer Brockerhoff via swift-evolution
On 3/19/16 09:03, Tino Heth via swift-evolution wrote: >> Just wanted to expand on the type tolerances idea with an example: >> >> let a:Float±0.1 = 1234.56 >> let b:Float±0.5 = 123.456 >> >> let result:Float±0.25 = a + b // Error as b’s tolerance > 0.25 > That example is a good motivation for two

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-19 Thread Tino Heth via swift-evolution
> Just wanted to expand on the type tolerances idea with an example: > > let a:Float±0.1 = 1234.56 > let b:Float±0.5 = 123.456 > > let result:Float±0.25 = a + b // Error as b’s tolerance > 0.25 That example is a good motivation for two things I would like to see in Swift: - Gene

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-19 Thread Haravikk via swift-evolution
Just wanted to expand on the type tolerances idea with an example: let a:Float±0.1 = 1234.56 let b:Float±0.5 = 123.456 let result:Float±0.25 = a + b // Error as b’s tolerance > 0.25 Of course this still requires developers to actually specify the tolerances at some point

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-18 Thread Haravikk via swift-evolution
I agree with all of this; I don’t really know enough to comment on the specific implementation of a decimal type, but we definitely need something other than NSDecimal. I don’t know if it’s possible, but I think that tolerances should be able to take a percentage. For example, I could write 0.0

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-18 Thread Dany St-Amant via swift-evolution
> Le 18 mars 2016 à 18:42, Rainer Brockerhoff via swift-evolution > a écrit : > > First draft towards a tentative pre-proposal: > https://gist.github.com/rbrockerhoff/6874a5698bb479886e83 > -- > > I propose, therefore, an internal data layout like this: > > UInt16 - position of the “virtu

Re: [swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-18 Thread Rainer Brockerhoff via swift-evolution
On 3/18/16 21:00, Dany St-Amant via swift-evolution wrote: > >> Le 18 mars 2016 à 18:42, Rainer Brockerhoff via swift-evolution >> a écrit : >> >> First draft towards a tentative pre-proposal: >> https://gist.github.com/rbrockerhoff/6874a5698bb479886e83 >> -- >> >> I propose, therefore, an i

[swift-evolution] Pre-proposal: Safer Decimal Calculations

2016-03-18 Thread Rainer Brockerhoff via swift-evolution
First draft towards a tentative pre-proposal: https://gist.github.com/rbrockerhoff/6874a5698bb479886e83 -- Pre-proposal: Safer Decimal Calculations Proposal: TBD Author(s): Rainer Brockerhoff Status: TBD Review manager: TBD Quoting the “The Swift Programming Language” book: “Swift adopts safe