R/MRatCalcpowered by RiX

RiX walkthrough 2 b

Number notation

Common exact inputs, then repeating decimals, bases, intervals, and output forms.

Begin with common exact inputs

Ordinary integers, finite decimals and fractions are exact by default. A colon makes an interval with exact endpoints. This short path is enough before Intervals and Recipe scaling.

Runnable RiX

The rest of this page is a reference tour of additional spellings. You can return to it when a calculation needs a repeating decimal, another base, a certified prefix or a display format.

Notation tour

RiX distinguishes exact values, certified uncertain scalars, and interval collections. Its number syntax covers integers, rational division, finite and repeating decimals, mixed numbers, radix shifts, continued fractions, exact intervals, certified prefixes, and bases without passing through floating point.

Predict the type and exact value of each input form before looking at its display.

A worked example

Runnable RiX

The final line is the displayed value; the earlier lines set up the experiment. Keep the setup visible so you can tell whether a name, a cell, or a collection is being reused when the expression changes.

Exact scalar input forms

Integer and finite-decimal input is exact. / is the exact division operator, so 3 / 4 evaluates to a Rational rather than a floating value. A repeating marker describes an infinite rational pattern exactly:

Runnable RiX

# begins the repeating digits. Continued fractions use .~; a leading ~ makes a signed first coefficient explicit, while unary - negates the entire continued fraction. _^ is RiX's exact radix-shift notation: 1.25_^3 means 1.25 * 10^3, not an inexact scientific-number literal.

RiX deliberately does not accept E/e exponent input. Use _^. Underscores group digits without changing the value, and {digits~count} compresses a long run, so 0.{0~7}1 is exactly 0.00000001.

Exact interval input forms

A colon constructs an exact closed interval. Decimal brackets provide compact suffix and last-place-offset forms, including exact repeating endpoints:

Runnable RiX

Unsigned bracket entries append digits. Signed entries are offsets measured in units of the last visible place; 1.2[+-0.1] is therefore 1.2 +/- 0.01. Intervals are collections of possible values, unlike the uncertain scalars in the next section.

Certified finite approximations

Inside a number, ? marks the end of the certified prefix. Digits or continued fraction coefficients after it remain useful candidate data, but do not narrow the authoritative enclosure:

Runnable RiX

Halo neighborhoods

A halo requests bounded refinement around an exact comparison target. It does not enlarge that target or define approximate equality:

Runnable RiX

Membership is true when x's enclosure fits in the target interval, false when disjoint, and ? only for overlap. The disjoint 0.5495 example is false even though it lies within epsilon of the interval. Optional limits are a map: {~ target, epsilon, {= timeout=2, memory=64_000_000, maxWork=5000 } }. Requester and provider limits combine by taking the more restrictive bound.

23.456?789 has candidate 23.456789 and certified enclosure 23.456:23.457. A bracket may certify a compatible tighter bound, as in 23.456?789[+-12]. Derived and provider values use a parseable explicit form such as 23.556?[=5889/250:23557/1000] when no honest shared digit prefix describes the full enclosure.

Arithmetic preserves the uncertain scalar and its exact enclosure. A comparison produces true, false, or standalone undecided ?:

Runnable RiX

The first result is 24.456?789: candidate digits participate in arithmetic and remain visible when that spelling reconstructs exactly the derived enclosure. When it cannot, RiX uses candidate?[=low:high]; the = labels the following interval as authoritative and is not an arithmetic operation.

Every built-in base prefix

The built-in prefixes are binary 0b, ternary 0t, quaternary 0q, base 5 0f, base 7 0s, octal 0o, duodecimal 0d, hexadecimal 0x, base 20 0v, base 36 0u, base 60 0m, and base 64 0y. 0z[N] selects a base from 2 through 64 directly:

Runnable RiX

Lowercase prefixes are built in. An uppercase prefix can be registered once with syntax such as 0A = "0123456789ABCDEF". For local conversion without a global prefix, use a digit-alphabet string or {: radix, digits } tuple:

Runnable RiX

Prefixed values may be ordinary radix values, fractions, mixed numbers, continued fractions, or certified prefixes. Uppercase custom prefixes also support quoted streams such as 0A"4A.F" when the alphabet contains characters that would otherwise end a token.

Exact and display output styles

Receiver methods expose the common base-10 Core representations. _> exposes the formatting modes uniformly and returns a string:

Runnable RiX

The mode aliases are / or fraction, .. or mixed, ./#/repeat, .~ or cf, ~ or cf_explicit, and ^/_^/shifted. A numeric base or named/custom base can be paired with a mode. <_ reverses parseable base output:

.~ is the ordinary continued-fraction spelling; ~ adds an explicit leading marker for contexts where the start could be ambiguous.

Runnable RiX

Session input and display settings

The compact *> directive selects one or more presentation views. Commas mean “show all of these,” not “choose one”:

Runnable RiX

That displays a decimal with at most twelve fractional places, binary, and a mixed fraction. The exact Rational underneath those views is still 7/4.

Session profiles also accept cf, sci[n], and sci-period[n] for continued-fraction and scientific views. The same profile formats both endpoints of an interval without changing its exact or oriented value.

<* selects the base of strict # input. Ordinary literals stay decimal, so a script can be explicit about which notation it is using and can change that notation midway through:

Runnable RiX

The long equivalents are .Config.NumInput("b") and .Config.NumDisplay(".[12],b,.."). .Config.Number accepts both in a map. RatCalc's Numbers panel controls the same session values and can optionally remember them in this browser.

Strict # forms and exact reinsertion

The tokenizer treats each strict numeral as one unit. A repeat marker is an internal second #; mixed and continued-fraction modes propagate the initial base marker through their components:

Runnable RiX

Space or an operator ends an ordinary strict literal. A dot remains part of the literal, which makes a possibly ambiguous method spelling fail. Write (#101).ToString(), not #101.ToString().

The last fraction is an ordinary division expression, so each operand needs its own #; #101/10 intentionally mixes active-base and decimal operands and receives a lint warning. The same warning catches redundant or partial inner markers such as #101..#11/1110.

Presentation is not serialization. _>! asks for lossless, parseable RiX source and fails when that guarantee cannot be met:

Runnable RiX

RatCalc follows the same rule when you click an output to put it back into the input: a displayed 0.142… injects the exact 1/7.

Generalized positional systems

Custom definitions use {: radix, digits, offset }. The offset is the value of the first digit, so the same codec covers balanced, negative-radix, and bijective writing systems:

Runnable RiX

The values are 2, -5, and 27; the last item is a balanced-ternary fraction string. Generalized systems support integer components, fractions, and mixed fractions. Conventional radix points and repeating-place expansions are intentionally rejected for these systems until a system-specific fractional-place rule is supplied.

Operator characters can be digits too, but their input must be quoted so the token boundary is unambiguous:

Runnable RiX

Here # selects the active P system and the backticks make ++ one digit stream, whose value is three. Each mixed-number or continued-fraction component is isolated because punctuation digits could otherwise hide the structural separators. Exact output adds quoted 0P prefixes to both fraction components, so evaluating source recreates 3/2.

Limits: display truncation versus certification

A limit appended to radix or shifted mode, such as .12 or ^12, may end in .... That is deliberately display-only and does not describe a new numeric value. Ask for a certified approximation when the limited result must remain parseable and safe for arithmetic:

Runnable RiX

ToDecimal() is also a display string when the decimal does not terminate; use ToDecimalApproximation or certified-conversion operator ~> when omitted digits must carry a guarantee. Unlike _>, ~> returns a numeric exact value or CertifiedApproximation, never a mere display string.

Receiver option maps and locale display

Complicated formatting options use maps. long=1 chooses the alternate finite continued fraction ending in 1. Locale is display-only—RiX source remains locale-independent:

Runnable RiX

All Core exact, repeating-period, continued-fraction, and interval display families now have RiX receiver methods. Core's E scientific string is the one intentional exception: RiX uses _> mode "_^" because E notation is not a RiX number syntax. _> covers the common parseable styles; receiver maps cover period metadata, alternate continued fractions, interval spellings, and locale.

Choose one unfamiliar spelling and compare it with an ordinary rational expression for the same value.

Keep going

Continue with Intervals or Recipe scaling for an exact calculation.