rational.toNumber
This function gives the nearest double to the value, with ties to even. The error is at most half a unit in the last place. A value past the range of the doubles gives an infinity, and a value too small gives 0 or a subnormal.
CLI- Package
- @procedures/rational · README
- Path
["rational","toNumber"]- CLI
mark rational toNumber --a <object>- As data
{"$proc":["rational","toNumber"],"input":{}}
Use it
In TypeScript
import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/rational/register"; // registers its procedures
const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["rational","toNumber"], { a: {} });
console.log(JSON.stringify(result));From the command line
$ mark rational toNumber --a <object>
As data, in a program
{ "$proc": ["rational", "toNumber"], "input": { "a": {} } }Input
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
a | object | yes |
Output
The schema does not list fields (number).
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"a": {
"type": "object",
"properties": {
"n": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
},
"d": {
"type": "string",
"pattern": "^-?(0|[1-9][0-9]*)$",
"x-procedures-codec": "bigint"
}
},
"required": [
"n",
"d"
],
"additionalProperties": {}
}
},
"required": [
"a"
],
"additionalProperties": false
},
"output": {
"type": "number"
}
}