STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
stardesign.jsformat Namespace Reference

Functions

str|None _special (float f)
str js_number (Any x)
str js_to_fixed (Any x, int digits)

Detailed Description

Numbers written the way JavaScript writes them.

Some files the apps hand out (EngineDesign's pressure-curve CSV, feed-twin's
plot CSV) used to be built in the browser. Now the backends write them, and the
files must not change in the move, so the numbers in them are printed by these:

- ``js_number(x)`` is ``String(x)``: ECMAScript Number::toString over the
  shortest round-trip digits, which Python's ``repr`` also produces;
- ``js_to_fixed(x, d)`` is ``x.toFixed(d)``: the exact binary value rounded to
  ``d`` places, a tie going away from zero (Python's own format rounds a tie to
  even, so ``f"{0.125:.2f}"`` is ``0.12`` where JavaScript writes ``0.13``).

Function Documentation

◆ _special()

str | None stardesign.jsformat._special ( float f)
protected

Definition at line 21 of file jsformat.py.

Referenced by js_number(), and js_to_fixed().

◆ js_number()

str stardesign.jsformat.js_number ( Any x)

Definition at line 29 of file jsformat.py.

References _special().

Referenced by js_to_fixed().

◆ js_to_fixed()

str stardesign.jsformat.js_to_fixed ( Any x,
int digits )

Definition at line 56 of file jsformat.py.

References _special(), format(), and js_number().