apple / swift-numerics

Advanced mathematical types and functions for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Real required BinaryFloatingPoint instead of FloatingPoint

vliegeois opened this issue · comments

Real is based among others on FloatingPoint protocol.

Would it make sense instead to based it on BinaryFloatingPoint.
It would allow more easily to do converting of instance of real into one type such as Double, Float.
For instance, if I have a generic type with Element that conform to Real, I sometimes need to interact with api that are not generic such as double3x3 and so I need convert into Double
let value: Element = .zero
let doubleValue = Double(value)

But for that, I need to add BinaryFloatingPoint as a requirement for my extension.
Would it make sense to directly make Real conform to BinaryFloatingPoint?

Vincent

We want to accommodate decimal floating point types too.

What @xwu said.

There's definitely some ergonomics improvements that are needed to make these conversions easier to handle, but we should fix those, instead of making Real refine BinaryFloatingPoint.

Closing this, please open a new issue or post on the forums for further questions.