> On Feb 23, 2017, at 11:31 AM, David Sweeris <[email protected]> wrote: > > > On Feb 23, 2017, at 07:33, plx via swift-evolution <[email protected] > <mailto:[email protected]>> wrote: >> >> Next quibble: `Magnitude` being defined as the “absolute value” of the >> underlying type seems a bit nonsensical if e.g. `Number` is intended to be >> adoptable by complex numbers (let alone quaternions, matrices, and whatnot). >> What *would* a conforming complex # implementation be expected to return as >> e.g. `(1-i).magnitude`? > > sqrt(2), I believe, or as close to it as can be represented by `Magnitude`
…which is what I’d expect if `x.magnitude` is supposed to be `||x||` or whatnot, but the stated motivation is: /// The magnitude of this value. /// /// For any numeric value `x`, `x.magnitude` is the absolute value of `x`. /// You can use the `magnitude` property in operations that are simpler to /// implement in terms of unsigned values, such as printing the value of an /// integer, which is just printing a '-' character in front of an absolute /// value. /// /// let x = -200 /// // x.magnitude == 200 …for which uses the norm is not really helpful (and `Magnitude` not being `Comparable` is pretty annoying if it’s intended to be a norm; it really seems only intended to work as a generic tool for writing pretty-printers).
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
