> On Jan 16, 2018, at 15:32 , Xiaodi Wu via swift-evolution > <swift-evolution@swift.org> wrote: > > On Jan 16, 2018, at 14:30 , Nevin Brackett-Rozinsky via swift-evolution > <swift-evolution@swift.org> wrote: >> >> That only works for numbers which don’t overflow the integer literals >> though. If we want a really large or small value then we have to split it in >> pieces: >> >> func moles <T: FloatingPoint> (particles: T) -> T { >> let avogadroNumber: T = 6_022_140_857 * 100_000_000_000_000 >> return particles / avogadroNumber >> } >> >> It would be much nicer to write “let avogadroNumber: T = 6.022140857e23”. >> > > You could write: > > func moles<T : FloatingPoint & LosslessStringConvertible>(particles: T) -> T { > let N_A = T("6.02214085774e+23")! > return particles / N_A > }
You're not seriously proposing this alternative, are you? I'm with Nevin on this: “let avogadroNumber: T = 6.022140857e23”. -- Rick Mann rm...@latencyzero.com _______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution