Wikifunctions:Type proposals/Rational number
Summary
A rational number is a number that can be expressed as a fraction with both numerator and denominator being integers and with the denominator not being equal to zero. (So we need integers before we can have rationals, but we could have non-negative rationals using just natural numbers.)
Uses
A Rational number is the most precise representation of the result of division. It can be displayed with an arbitrarily large number of decimal places, or in bases other than base 10. Equally, it can be displayed as a fraction or an integer and a remainder. Such transformations may lead to a loss of precision, but the value represented by the object is not changed by them.
See en:Rational_data_type#Language_support for programming languages that support Rational numbers as a primitive data type or extension.
Structure
A rational number is an object with two additional keys, one containing a string representing the integer value of the numerator and the other containing a string representing the integer value of the denominator.
Example values
Value 0
{
"type": "natural number",
"value": "0"
}
|
{
"Z1K1": "Z10",
"Z10K1": "0"
}
|
Persistent objects
None.
Validator
The validator ensures that:
Identity
Two … are the same if
Converting to code
Python
JavaScript
Renderer
Renderers are the responsibility of the community.
They output
Parsers
Parsers are the responsibility of the community.