← All procedures
rational.fromFloat
This function gives the exact value of a finite double. Thus `0.1` gives 3602879701896397/2^55. The value `-0` gives 0.
CLI- Package
- @procedures/rational · README
- Path
["rational","fromFloat"]- CLI
mark rational fromFloat --value <number>- As data
{"$proc":["rational","fromFloat"],"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","fromFloat"], { value: 1 });
console.log(JSON.stringify(result));From the command line
$ mark rational fromFloat --value <number>
As data, in a program
{ "$proc": ["rational", "fromFloat"], "input": { "value": 1 } }Input
Output
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"value": {
"type": "number"
}
},
"required": [
"value"
],
"additionalProperties": false
},
"output": {
"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": {}
}
}