Re: [swift-users] abs() Bug?

2017-12-12 Thread Stephen Canon via swift-users
Please note that silently returning an incorrect value instead of crashing is the exact opposite of “safety” as understood in Swift. (These should all crash, and as others have reported, they do in my environment. If you can reproduce abs(Int32.min), please report a bug with your swift compiler

Re: [swift-users] Modulo operation in Swift?

2017-11-09 Thread Stephen Canon via swift-users
Use fmod(x,y). It is identical to C fmod(x,y). It’s also identical to x.truncatingRemainder(dividingBy: y). > On Nov 9, 2017, at 1:12 PM, Roderick Mann wrote: > > Ah, I see. > > So, here's my issue. I recently ported some C code for satellite position > prediction to Swift. This code used fmo

Re: [swift-users] Modulo operation in Swift?

2017-11-09 Thread Stephen Canon via swift-users
> On Nov 9, 2017, at 10:55 AM, Rick Mann via swift-users > wrote: > > Why is % not available for floating point numbers? This has been discussed extensively. Swift had this this operator originally, but we removed it. Here’s the rationale I gave back then: --- While C and C++ do not

Re: [swift-users] FloatingPoint equality ..

2017-06-29 Thread Stephen Canon via swift-users
> On Jun 29, 2017, at 2:40 PM, Gavin Eadie via swift-users > wrote: > > I've spent a fascinating evening and morning in the arcane depths of floating > point, specifically researching the comparison of two floating point numbers. > I pretty much understand how to do this with a combination

Re: [swift-users] FloatingPoint equality ..

2017-06-29 Thread Stephen Canon via swift-users
I should also point out: (a) your code can be somewhat simpler in Swift. I would probably write something along the lines of: func almostEqual(_ a: T, _ b: T) -> Bool { return a >= b.nextDown && a <= b.nextUp } (b) one ULP is almost never a tolerance you want to use. It’s much too small fo

Re: [swift-users] Decimal to Double?

2016-11-28 Thread Stephen Canon via swift-users
> On Nov 28, 2016, at 2:29 PM, David Sweeris via swift-users > wrote: > > Sent from my iPhone >> On Nov 28, 2016, at 13:21, Joe Groff wrote: >> >> It really shouldn't be, since ExpressibleByFloatLiteral uses a binary float >> initial value and so doesn't guarantee decimal accuracy. I'd recom

Re: [swift-users] Provide native Decimal data type

2016-09-12 Thread Stephen Canon via swift-users
> On Sep 12, 2016, at 1:26 PM, Jens Alfke via swift-users > wrote: > >> On Sep 12, 2016, at 10:10 AM, Teej . via swift-users > > wrote: >> >> …in spite of the CPU’s quirks in handling floating point numbers in a >> maddening inaccurate manner. > > Well, in

Re: [swift-users] An OpenGL math library in pure Swift

2016-01-05 Thread Stephen Canon via swift-users
t; Best Regards, > Volodymyr Boichentsov > >> On 5 Jan 2016, at 16:59, Stephen Canon via swift-users >> mailto:swift-users@swift.org>> wrote: >> >> Hey David — >> >> FYI essentially all of this stuff is already present in the simd module >> (st

Re: [swift-users] An OpenGL math library in pure Swift

2016-01-05 Thread Stephen Canon via swift-users
Hey David — FYI essentially all of this stuff is already present in the simd module (stdlib/public/SDK/simd/simd.swift.gyb or ‘import simd'), albeit without nice generics, and with some different stylistic choices because simd is at present a straight Swift port of a subset of the simd C/Obj-C/

Re: [swift-users] scientific library for swift?

2015-12-22 Thread Stephen Canon via swift-users
Surge sits on Accelerate.framework, which is Apple-specific (i.e. OS X / iOS only). – Steve > On Dec 22, 2015, at 8:50 PM, Donald Pinckney wrote: > > I'm not sure if this fully addresses your needs, but it seems pretty close: > > https://github.com/mattt/Surge/