[swift-evolution] [Pitch] Percentage Type

Jonathan Hull jhull at gbis.com
Sat Jan 13 20:26:22 CST 2018


Hi Evolution,

I was wondering if we would consider adding a percentage type to Swift.  This would be a type with a value between 0 & 1.

I know we can and do use doubles or floats for this now, but there really is a semantic difference between most parameters that take a value between 0 & 1 and those that take any floating point value.  It would be nice to have a type that semantically means that the value is from 0 to 1.

It could even just wrap a Double for speed (in my own code I wrap a UInt64 for decimal accuracy… and to avoid issues around comparisons).

Thanks,
Jon


More information about the swift-evolution mailing list