Double - leacode/SwiftWings GitHub Wiki

Double Extensions

Source: Sources/Extensions/Foundation/Double

Tests: Tests/Extensions/Double

Double+Extensions.swift

  • toString() formats to two decimal places via String(format:).
  • BinaryFloatingPoint.toInt() performs a simple Int cast for any floating-point value.

Double+ChineseCurrency.swift

  • chineseMoneySpell formats a decimal as uppercase RMB (壹贰叁…) using NumberFormatter with the zh_Hans_CN locale and additional replacements.

Example

let price = 1234.5
print(price.toString()) // "1234.50"
print(price.chineseMoneySpell ?? "") // "壹仟贰佰叁拾肆圆伍角"
print((12.5 as BinaryFloatingPoint).toInt()) // 12
⚠️ **GitHub.com Fallback** ⚠️