Skip to content

Releases: swift-standards/swift-iso-9899

swift-iso-9899 v0.1.0

24 Nov 11:30

Choose a tag to compare

swift-iso-9899 v0.1.0

Initial release of swift-iso-9899 - a comprehensive Swift implementation of ISO/IEC 9899:2018 (C Standard) mathematical functions.

Features

Complete ISO/IEC 9899:2018 Section 7.12 Implementation

  • Classification Functions (Section 7.12.3): fpclassify, isfinite, isinf, isnan, isnormal, signbit
  • Trigonometric Functions (Section 7.12.4): sin, cos, tan, asin, acos, atan, atan2
  • Hyperbolic Functions (Section 7.12.5): sinh, cosh, tanh, asinh, acosh, atanh
  • Exponential and Logarithmic Functions (Section 7.12.6): exp, log, exp2, log2, log10, expm1, log1p
  • Power and Absolute-Value Functions (Section 7.12.7): pow, sqrt, cbrt, hypot, fabs
  • Error and Gamma Functions (Section 7.12.8): erf, erfc, tgamma, lgamma
  • Rounding Functions (Section 7.12.9): ceil, floor, round, trunc, rint, nearbyint, lround, llround
  • Remainder Functions (Section 7.12.10): fmod, remainder, remquo
  • Manipulation Functions (Section 7.12.11): copysign, nan, nextafter, nexttoward
  • Comparison Functions (Section 7.12.14): isgreater, isgreaterequal, isless, islessequal, islessgreater, isunordered
  • Mathematical Constants: M_E, M_PI, M_SQRT2, and more

Ergonomic API

// Namespace API
let result = ISO_9899.Math.sin(1.0)

// Swifty .c namespace
let value = Double.c.sin(1.0)
let sqrt = Float.c.sqrt(4.0)

Cross-Platform Support

  • macOS (x86_64, ARM64)
  • Linux (x86_64)
  • Foundation-free implementation

Installation

Add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/swift-standards/swift-iso-9899.git", from: "0.1.0")
]

Platform Notes

The nexttoward functions are implemented with cross-platform compatibility:

  • macOS x86_64: Uses native 80-bit long double precision
  • macOS ARM64 & Linux: Uses double precision (platform limitation)
  • API surface remains consistent across all platforms