|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +@_exported import _Builtin_float |
| 14 | + |
| 15 | +@available(swift, deprecated: 3.0, message: "Please use 'T.radix' to get the radix of a FloatingPoint type 'T'.") |
| 16 | +public let FLT_RADIX = Double.radix |
| 17 | + |
| 18 | +%for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]: |
| 19 | +% if type == "Float80": |
| 20 | +#if !os(Android) && !os(WASI) && !os(Windows) && (arch(i386) || arch(x86_64)) |
| 21 | +% end |
| 22 | +// Where does the 1 come from? C counts the usually-implicit leading |
| 23 | +// significand bit, but Swift does not. Neither is really right or wrong. |
| 24 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.significandBitCount + 1'.") |
| 25 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 26 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 27 | +public let ${prefix}_MANT_DIG = ${type}.significandBitCount + 1 |
| 28 | + |
| 29 | +// Where does the 1 come from? C models floating-point numbers as having a |
| 30 | +// significand in [0.5, 1), but Swift (following IEEE 754) considers the |
| 31 | +// significand to be in [1, 2). This rationale applies to ${prefix}_MIN_EXP |
| 32 | +// as well. |
| 33 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude.exponent + 1'.") |
| 34 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 35 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 36 | +public let ${prefix}_MAX_EXP = ${type}.greatestFiniteMagnitude.exponent + 1 |
| 37 | + |
| 38 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude.exponent + 1'.") |
| 39 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 40 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 41 | +public let ${prefix}_MIN_EXP = ${type}.leastNormalMagnitude.exponent + 1 |
| 42 | + |
| 43 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.greatestFiniteMagnitude' or '.greatestFiniteMagnitude'.") |
| 44 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 45 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 46 | +public let ${prefix}_MAX = ${type}.greatestFiniteMagnitude |
| 47 | + |
| 48 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.ulpOfOne' or '.ulpOfOne'.") |
| 49 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 50 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 51 | +public let ${prefix}_EPSILON = ${type}.ulpOfOne |
| 52 | + |
| 53 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNormalMagnitude' or '.leastNormalMagnitude'.") |
| 54 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 55 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 56 | +public let ${prefix}_MIN = ${type}.leastNormalMagnitude |
| 57 | + |
| 58 | +@available(swift, deprecated: 3.0, message: "Please use '${type}.leastNonzeroMagnitude' or '.leastNonzeroMagnitude'.") |
| 59 | +@available(macOS 10.9, iOS 7.0, tvOS 7.0, watchOS 2.0, *) |
| 60 | +@_originallyDefinedIn(module: "Darwin", macOS 9999, iOS 9999, watchOS 9999, tvOS 9999) |
| 61 | +public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude |
| 62 | + |
| 63 | +% if type == "Float80": |
| 64 | +#endif |
| 65 | +% end |
| 66 | +%end |
0 commit comments