Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ expressed as JSON Schema definitions.

| Organisation | Standard | Title |
|--------------|----------|-------|
| IEEE | [IEEE Std 754-2019](https://ieeexplore.ieee.org/document/8766229) | IEEE Standard for Floating-Point Arithmetic |
| IEEE | [IEEE Std 1003.1-2017](https://pubs.opengroup.org/onlinepubs/9699919799/) | IEEE Standard for Information Technology—Portable Operating System Interface (POSIX) Base Specifications, Issue 7 |
| IETF | [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) | Uniform Resource Identifier (URI): Generic Syntax |
| IETF | [RFC 4918](https://www.rfc-editor.org/rfc/rfc4918) | HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV) |
Expand Down
27 changes: 27 additions & 0 deletions schemas/ieee/floating-point/2019/binary16-special.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Half Precision Binary Floating-Point with Special Values (binary16)",
"description": "A 16-bit binary floating-point format, extended to accept special values as strings",
"examples": [
0.0,
1.0,
-1.0,
3.14,
65504.0,
-65504.0,
"NaN",
"+Inf",
"-Inf",
"qNaN"
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"anyOf": [
{
"$ref": "./binary16.json"
},
{
"$ref": "./special.json"
}
]
}
11 changes: 11 additions & 0 deletions schemas/ieee/floating-point/2019/binary16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Half Precision Binary Floating-Point (binary16)",
"description": "A 16-bit binary floating-point format. Also known as half precision",
"examples": [ 0.0, 1.0, -1.0, 3.14, 65504.0, -65504.0, 6.10352e-05 ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"type": "number",
"maximum": 65504.0,
"minimum": -65504.0
}
26 changes: 26 additions & 0 deletions schemas/ieee/floating-point/2019/binary32-special.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Single Precision Binary Floating-Point with Special Values (binary32)",
"description": "A 32-bit binary floating-point format, extended to accept special values as strings",
"examples": [
0.0,
1.5,
-3.14,
340282346638528859811704183484516925440.0,
-340282346638528859811704183484516925440.0,
"NaN",
"+Inf",
"-Inf",
"sNaN"
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"anyOf": [
{
"$ref": "./binary32.json"
},
{
"$ref": "./special.json"
}
]
}
18 changes: 18 additions & 0 deletions schemas/ieee/floating-point/2019/binary32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Single Precision Binary Floating-Point (binary32)",
"description": "A 32-bit binary floating-point format",
"examples": [
0.0,
1.5,
-3.14,
340282346638528859811704183484516925440.0,
-340282346638528859811704183484516925440.0,
1.4013e-45
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"type": "number",
"maximum": 340282346638528859811704183484516925440.0,
"minimum": -340282346638528859811704183484516925440.0
}
27 changes: 27 additions & 0 deletions schemas/ieee/floating-point/2019/binary64-special.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Double Precision Binary Floating-Point with Special Values (binary64)",
"description": "A 64-bit binary floating-point format",
"examples": [
0.0,
1.5,
-3.14159,
299800000.0,
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"NaN",
"+Inf",
"-Inf",
"qNaN"
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"anyOf": [
{
"$ref": "./binary64.json"
},
{
"$ref": "./special.json"
}
]
}
18 changes: 18 additions & 0 deletions schemas/ieee/floating-point/2019/binary64.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Double Precision Binary Floating-Point (binary64)",
"description": "A 64-bit binary floating-point format",
"examples": [
0.0,
1.5,
-3.14159,
299800000.0,
179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
-179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"type": "number",
"maximum": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"minimum": -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
}
9 changes: 9 additions & 0 deletions schemas/ieee/floating-point/2019/special.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "IEEE 754-2019 Special Floating-Point Values",
"description": "Special floating-point values: NaN (Not-a-Number) with quiet and signaling variants, and positive/negative infinities",
"examples": [ "NaN", "qNaN", "sNaN", "+Inf", "-Inf" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://ieeexplore.ieee.org/document/8766229" ],
"enum": [ "NaN", "qNaN", "sNaN", "+Inf", "-Inf" ]
}
7 changes: 2 additions & 5 deletions schemas/iso/c/2024/double.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Double Precision Floating Point (double)",
"description": "A double precision (64-bit) floating point type conforming to IEC 60559 (IEEE 754)",
"$comment": "The minimum and maximum represent `DBL_MAX` and `-DBL_MAX`. Special floating-point values are defined in a separate schema",
"description": "A double precision (64-bit) floating point type",
"examples": [
0.0,
1.5,
Expand All @@ -18,9 +17,7 @@
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"anyOf": [
{
"type": "number",
"maximum": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0,
"minimum": -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.0
"$ref": "../../../ieee/floating-point/2019/binary64.json"
},
{
"$ref": "./float-special.json"
Expand Down
2 changes: 1 addition & 1 deletion schemas/iso/c/2024/float-special.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Special Floating-Point Values",
"description": "Special floating-point values as defined in `<math.h>`. These are represented as strings since JSON numbers cannot express these values",
"description": "Special floating-point values as defined in `<math.h>`",
"examples": [ "NAN", "INFINITY", "-INFINITY" ],
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"x-links": [ "https://www.iso.org/standard/82075.html" ],
Expand Down
11 changes: 4 additions & 7 deletions schemas/iso/c/2024/float.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "ISO/IEC 9899:2024 Single Precision Floating Point (float)",
"description": "A single precision (32-bit) floating point type conforming to IEC 60559 (IEEE 754)",
"$comment": "The minimum and maximum represent `FLT_MAX` and `-FLT_MAX`. Special floating-point values are defined in a separate schema",
"description": "A single precision (32-bit) floating point type",
"examples": [
0.0,
1.5,
-3.14,
340282346600000016151267322115014000640.0,
-340282346600000016151267322115014000640.0,
340282346638528859811704183484516925440.0,
-340282346638528859811704183484516925440.0,
"NAN",
"INFINITY",
"-INFINITY"
Expand All @@ -17,9 +16,7 @@
"x-links": [ "https://www.iso.org/standard/82075.html" ],
"anyOf": [
{
"type": "number",
"maximum": 340282346600000016151267322115014000640.0,
"minimum": -340282346600000016151267322115014000640.0
"$ref": "../../../ieee/floating-point/2019/binary32.json"
},
{
"$ref": "./float-special.json"
Expand Down
101 changes: 101 additions & 0 deletions test/ieee/floating-point/2019/binary16-special.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/ieee/floating-point/2019/binary16-special.json",
"tests": [
{
"description": "Valid - zero",
"data": 0.0,
"valid": true
},
{
"description": "Valid - positive value",
"data": 1.0,
"valid": true
},
{
"description": "Valid - negative value",
"data": -1.0,
"valid": true
},
{
"description": "Valid - maximum value",
"data": 65504.0,
"valid": true
},
{
"description": "Valid - minimum value",
"data": -65504.0,
"valid": true
},
{
"description": "Valid - NaN",
"data": "NaN",
"valid": true
},
{
"description": "Valid - qNaN",
"data": "qNaN",
"valid": true
},
{
"description": "Valid - sNaN",
"data": "sNaN",
"valid": true
},
{
"description": "Valid - +Inf",
"data": "+Inf",
"valid": true
},
{
"description": "Valid - -Inf",
"data": "-Inf",
"valid": true
},
{
"description": "Invalid - above maximum",
"data": 70000.0,
"valid": false
},
{
"description": "Invalid - below minimum",
"data": -70000.0,
"valid": false
},
{
"description": "Invalid - lowercase nan",
"data": "nan",
"valid": false
},
{
"description": "Invalid - C23 style NAN",
"data": "NAN",
"valid": false
},
{
"description": "Invalid - C23 style INFINITY",
"data": "INFINITY",
"valid": false
},
{
"description": "Invalid type - boolean",
"data": false,
"valid": false
},
{
"description": "Invalid type - null",
"data": null,
"valid": false
},
{
"description": "Invalid type - array",
"data": [],
"valid": false
},
{
"description": "Invalid type - object",
"data": {},
"valid": false
}
]
}
81 changes: 81 additions & 0 deletions test/ieee/floating-point/2019/binary16.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE",
"target": "../../../../schemas/ieee/floating-point/2019/binary16.json",
"tests": [
{
"description": "Valid - zero",
"data": 0.0,
"valid": true
},
{
"description": "Valid - positive value",
"data": 1.0,
"valid": true
},
{
"description": "Valid - negative value",
"data": -1.0,
"valid": true
},
{
"description": "Valid - pi approximation",
"data": 3.14,
"valid": true
},
{
"description": "Valid - maximum value",
"data": 65504.0,
"valid": true
},
{
"description": "Valid - minimum value",
"data": -65504.0,
"valid": true
},
{
"description": "Valid - small positive value",
"data": 6.10352e-05,
"valid": true
},
{
"description": "Valid - small negative value",
"data": -6.10352e-05,
"valid": true
},
{
"description": "Invalid - above maximum",
"data": 70000.0,
"valid": false
},
{
"description": "Invalid - below minimum",
"data": -70000.0,
"valid": false
},
{
"description": "Invalid type - boolean",
"data": false,
"valid": false
},
{
"description": "Invalid type - null",
"data": null,
"valid": false
},
{
"description": "Invalid type - string",
"data": "1.0",
"valid": false
},
{
"description": "Invalid type - array",
"data": [],
"valid": false
},
{
"description": "Invalid type - object",
"data": {},
"valid": false
}
]
}
Loading