abs()

circle-info

func abs<T>(_ x: T) -> T where T : Comparablearrow-up-right, T : SignedNumericarrow-up-right

๐Ÿ‘‰ replitarrow-up-right

abs(-5),            // 5
abs(-3.45),         // 3.45
abs(Int.min)        // โŒ overflow

Last updated

Was this helpful?