Add character catalog when inside text.
Define character menus with various languages and shapes.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Inserting variables, constants or units in a program was broken.
Also a few less critical fixes.
== Bug fixes ==
* decimal: Apply `MinimumSignificantDigits` to `Sig` modes
* tests: Fix missing `]` at end of vector
* ui: Insert commands for unit conversions, constants and variables
* tests: Adjust help screen snapshot for authors
* menus: Do not clip text for hierarchical menus
* constants: Do not use units that don't parse correctly
* dmcp: Day of week convention adjustment
* help: Fix YouTube video preview
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
It is desirable to display `sin(10)` as `0.17...` instead of using
scientific notation. Ensure that:
1. `MinimumSignificantDigits` applies to `Sig` modes (incl. `Std`)
2. `StandardExponent` is respected for negative exponents
Fixes: #851
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release introduces a few major improvements, including graphical
rendering of equations and matrices, the `Show` command to display
large objects full-screen, customizable constants, and date-related
operations.
== New features ==
* Graphical rendering of equations, fractions, matrices, vectors and
lists. In graphical rendering mode, variables are showin in italics.
* Constants in the `ConstantsMenu`, split into categories, and loading
from an optional `config/constants.csv` file, in a way
similar to what existed for units.
* Inverse trigonometric functions (`asin`, `acos` and `atan`) now
produce unit objects with the current angle mode as a unit. This can
be configured by the `SetAngleUnits` / `NoAngleUnits` flags.
* `Cycle` (EEX key) now cycles between angle units.
* `R→D` and `D→R` commands to convert between degree and radian in a
purely numerical way (no unit). This is for compatibility with HP.
* Add `→Deg`, `→Rad`, `→Grad`, `→πr` commands, which convert a number
to the target unit using current angle mode, and convert an angle to
the target angle unit.
* Conversion from DMS to HMS and from HMS to DMS
* Rendering of dates: `19681205_date` renders as `Fri 5/Dec/1968`,
with a format configuration using the same flags as for the header.
Note that the date format is `YYYYMMDD`, _not_ the same as on HP
calculators. This allows `YYYYMMDD.hhmmss` for dates with time.
* `Date` and `Time` command to return the current date and time.
Additionally, `DateTime` returns both date and time, and
`ChronoTime` returns the time with 1/100s precision.
* `→Date` and `→Time` commands to set the system date and time
* `Date+`, `DDays` and date arithmetic using `+` or `-`, using day
units for the results. As an extension relative to HP calculators,
these will accept fractional days, or other time units. For example,
adding `1000000_s` to `19681205_date` generates a date with time
result, `Tue 16/Dec/1968, 13:46:40`
* `JulianDayNumber` and `DateFromJulianDayNumber` commands to convert
between dates and Julian day numbers. These commands also accept
fractional input.
* `Show` command showing a full-screen graphical rendering of the
result on the stack. The resut is size-adjusted. For example, you
can display all digits in `200!`. If the result does not fit on the
screen, you can scroll using the _◀︎_ and _▶︎_, as well as _8_, _6_,
_4_ and _2_. The maximum pixel size for `Show` is set by `MaxW`
(default is the width of the LCD), the maximum height is set by
`MaxH` (default is 2048 pixels).
* `AutoScaleStack` and `NoAutoScaleStack` settings to automatically
adjust the font size for the stack elements.
* Support for system flags -20 to -26 (infinite results, overflow and
underflow).
== Bug fixes ==
* simulator: Adjust DMCP month off-by-one error
* Repair insertion of `while` loops and similar commands on the
command line
* Use stack format when drawing an object with `DrawText` (`DISP`)
* Arithmetic on unit objects no longer auto-simplifies, e.g.
`1_s 1_s -` returns `0_s` and not `0`.
* Perform computations for `→Q` using integer values, which avoids an
issue where increasing the number of iterations with an unachievable
precision could prodduce `1/1` as the fractional result.
* Repair auto-simplification for `i*i=-1`
* Display a negative mixed fraction as `-1 1/3` and not `1 -1/3`.
* Do not insert `()` after a multiplication in algebraic mode
* Accept units and tagged objects in `PolarToReal` and `RealToPolar`
* Accept angle units as input for `→DMS`
* Off-by-one clipping error in header, erasing the shift annunciator
* Fix help for `FC?` (incorrectly stating that it tested for flat set)
* Lookup units and constants in a case sensitive way
* Fix labels for `ExpFit` and `LinFit` in `RegressionMenu`.
== Improvements ==
* tests: Adjust tests to match bugs fixed in v0.6.5
* dms: Accept entering minutes without third dot, e.g. `1.2.3 ENTER`
* menus: Split the Time, Date and Alarm menus
* Split rendered objects at space boundaries. This notably ensures
that large numbers are split at digit grouping boundaries, and makes
it possible to display larger programs on the stack. The rendering
of programs and matrices/vectors/lists has also been fine-tuned.
* The "white circle" glyph has a thicker border, makes it more
readable in menus.
* doc: Update the list of unimplemented features
* menus: Draw a white circle for disabled flags, and allow the menu
function to toggle the flag. This made it possible to reduce the
number of menu entries for flag-heavy menus.
* Mixed fractions are now the default, as opposed to improper fractions
* doc: Improve the quickstart guide, adding videos and screenshots
* doc: Improve the documentation for sin, cos and tan
* tests: Make it possible to interrupt a running test
* help: Skip HTML tags, e.g. <video>
* simulator: Add screenshot capability, and reduce window height
* menus: `ToolsMenu` selects time, date or angle menu based on units
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add support for the `InfinityValue` (-22) flag, described in the
HP50G as the "Infinite result exception" flag.
When the flag is set, infinite results are returned either as symbolic
constant infinity `∞` or as its value, currently defined as
`9.99999E999999`.
Whether the infinity value is returned symbolically or numerially
depends on the `NumericalConstants` (-2) and `NumericalResults` (-3)
flags.
Fixes: #835
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Show` command displays an object graphically using the entire
screen, with the possibility to scroll horizontally and vertically.
Fixes: #392
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Since this may require additional CPU power and drain the battery faster,
add a setting to disable stack auto-scaling.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `JulianDayNumber` returns the Julian day number for the input date.
This may be fractional if the input date contains a time, see `DateTime`.
See https://en.wikipedia.org/wiki/Julian_day for details
Fixes: #826
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the `→Date` command to set the system date,
and the `→Time` command to set the system time.
Fixes: #823
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Date` command returns the current date
The `Time` command returns the current time
The `DateTime` command returns the current date with time
Fixes: #666
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Dynamic constants menu, similar to units menu, which is populated
either from an internal table, or from `config/constants.csv`
Fixes: #497
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add `R→D` and `D→R` as purely numerical functions, compatible with HP-48.
Add `→Deg`, `→Rad`, `→Grad`, `→πr` commands, which
- Convert a number to the target unit using current angle mode
- Convert an angle to the target angle unit
Fixes: #811
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
When the `SetAngleUnits` setting is enabled, `asin`, `acos` and `atan`
will return values with an angle unit that corresponds to the current
angle mode.
The evaluation of such values should be independent from the current
angle mode.
Fixes: #807
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release does not contain much because FOSDEM took a lot of energy.
New features:
* menu: Connect `ceil` and `floor` functions
* Add real to polar conversions
* units: Add `dms` unit to angles menu
Bug fixes:
* decimal: Compute `ln(0.002)` correctly
* integer: Do not parse degree sign if in a complex
* units: Fix parsing of angle units
* font: Add radian glyph
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release focuses on heavy testing of the new variable-precision
decimal stack. Adding tests also means finding bugs.
Another significant change is support for fixed-precision
hardware-accelerated floating point, using 32-bit and 64-bit IEEE754
binary floating-point representation. Since this uses a binary format,
some decimal values do not map to decimal correctly. For example,
displaying 1.2 with a large number of decimals will show residue,
because 1.2 does not have an exact (zero-terminated) representation in
binary.
New features:
* plotting: Make refresh rate configurable
* menu: Add `/` key to `FractionsMenu`
* hwfp: Add support for hardware-accelerated floating-point
* menus: Add hardware floating-point flag to `MathModesMenu`
* ui: Allow multiple uses of `.` to insert DMS separators
* HMS: Editing of HMS values in HMS format
Bug fixes:
* stats: Fix crash on `variance` with single-column statistics
* algebraic: Clear error before evaluating the function
* functions: Correctly emit a type error for non-algebraics
* ui: Make sure we save stack if closing the editor
* logical: Fix mask for rotate left with 64-bit size
* logical: Make sure we save args for single-argument logicals
* flags: Update flags on `FlipFlag`, consume them from `BinaryToFlags`
* stack: Show multi-line objects correctly
* lists: Returns `Bad argument value` for index with bad arguments
* lists: Return an empty list for tail of empty list
* arithmetic: `→Frac` should not error on integers
* power: Do not shut down during `WAIT` if on USB power
Improvements:
* menu: Shorten the labels `→QIter` and `→QPrec` to avoid scrolling
* stack: Avoid running same code twice on simulator
* ids: Add aliases for hardware floating point
* functions: Optimize abs and neg
* ui: Replace calls to `rt.insert` with calls to `insert`
* menu: Reorganize fractions menu
* dms: Do the DMS conversion using fractions
* list: Adjust multi-line rendering
* copyright: Update copyright to 2024
* text: Return null text when indexing past end of text
Testing:
* tests: Increase the delay for help to draw
* tests: Add tests for hardware-accelerated floating-point
* tests: Add shifts and rotate tests
* tests: Check flag functions
* tests: Test DMS and HMS operations
* tests: Add test for `integrate` using decimal values
* tests: Test multi-line stack display
* tests: Add tests for `GETI`
* tests: Min and max commands
* tests: Repair last regression test
* tests: Check behaviour of 0^0
* tests: Avoid string overflow in case of very long message
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.
See numbers recorded in `doc/6-Performance.md` for details.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The focus of this release was to reactivate the test suite and fix the
problems that were found activating it.
[![Recording of a full run of the test suite](https://img.youtube.com/vi/aHW2GcX5S6o/maxresdefault.jpg)](https://www.youtube.com/watch?v=aHW2GcX5S6o&list=PLz1qkflzABy-Cs1R07zGB8A9K5Yjolmlf)
New features:
- HMS and DMS operations
- unit: Rendering of `dms` and `hms` units
- Allow `·` as a multiplication sign in equations
- ui: Display 'E' cursor inside parentheses
- graphics: Accept based integers as position for `DrawText`
- complex: Add setting to switch between `2+3i` and `2+i3`.
Bug fixes:
- decimal: Fix precision loss for addition with carry
- Base: limit range of bases to 2-36
- files: Do not add a trailing zero when reading a text file
- decimal: Adjust `MinimumSignificantDigits` behaviour
- units: Do not auto-simplify `1.0` during conversion
- decimal: Normalize parsed numbers
- solver: Fix sign error in epsilon exponent for solve/integrate
- parser: Accept `x!` as input
- simulator: Avoid faulty break-through in switch statement
- complex: Make tag higher-priority than complex
- editor: Adjust cursor and select correctly during replace
- decimal: Fix display of 0.2 in NoTrailingDecimal mode
- complex: Save `this` in a GC pointer when it can move
- arithmetic: Do not fail because of surrounding error
- decimal: Clamp int32 conversions from decimal
- commands: Parse `exp10` correctly in expressions
- decimal: Avoid infinite loop computing `expm1`
- ids: Do not allow parsing of structures
- dmcp: Make sure the tests don't block on `wait_for_key`
- decimal: Use correct angle unit for negative gamma values
Improvements:
- settings: Add classes that save/restore a given setting
- Add `XSHIFT` to shift to XSHIFT state directly
- Add NOSHIFT constant to simplify test writing
- ui: Add a variant of `close_editor` without trailing zero
- decimal: Cache gamma_ck values (accelerate gamma and lgamma)
- Replace magic constant `-1` with `EXIT_PGM`
- doc: Record performance data for 1000 iterations of SumTest
- decimal: Add tracing for gamma / lgamma function
New tests:
- Add tests for arithmetic truncation on short bitsizes
- Add tests for on-line help
- Add test for plotting flags
- Add test for Unicode to text conversions
- Add test for rectangular complex display options
- Add tests for plot scaling functions
- Add tests for the sorting functions
- Add test for parsing text with quotes inside
- Add test for file-based `STO` and `RCL`
- Add test for 2^256 computation (buf #460)
- Fix indentation of `[PASS]` or `[FAIL]` for UTF8 characters
- Add tests for units and conversions
- Add a keyboard test checking the single-colon insert in text
- Add test for i*i=-1 auto-simplification
- Add basic test for numerical integration
- Add test for fraction formats
- Add solver test
- Add missing tests
- Add test for immediate `STO` (#390)
- Add tests for the `Cycle` command
- Add test for catalog feature
- Add test for "smart" keyboard shortcuts introduced in 0.4.6
- Add regression test for #371
- Add tests for editor operations
- Test stack operations
- Add test for `GXor`, `GOr` and `GAnd`
- Add test for `ResetModes`
- Add plotting test for every decimal function
- Add image checking for graphical tests
- Add tests for graphic and text drawing commands
- Make it possible to individually run tests.
- Add plotting tests
- Add test parsing the various spellings for commands
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Allow `"Hello" #120d DrawText` to draw something in the middle of the
screen.
Fixes: #730
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
We need to start recording the performance data of the decimal code on
a release-to-release basis. Definitely much slower than before, hence
the need to be realistic and reduce the number of iterations.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Add the `ClearStack` (`CLEAR`) commands to clear the whole stack.
Also update the stack menu.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
A few quick bug fixes that make DB48X a bit more usable.
**New features**
* Setting to display `2+i3` instead of `2+3i` (#660)
* HMS and DMS operations (#654)
* Special `1_dms` and `1_hms` units rendering in DMS / HMS (#650)
**Bug fixes**
* Improve behavior of `+/-` key while editing (#658)
* Do not accept base 37 (#656)
* Insert `for` statement in program instead of executing it (#655)
* Hide trailing decimal separator for decimals with integer values (#653)
* Fix display of `19.8` with `0 FIX` (#652)
* Implement true decimal to integer conversion (#648)
**Improvements**
* doc: Record performance data for 0.6.0
* doc: Update status file
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Record the (bad) performance data for the variable-precision
decimal number representation.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release was a bit longer in coming than earlier ones, because we are about
to reach the limits of what can fit on a DM42. This release uses 711228 bytes
out of the 716800 (99.2%).
Without the Intel Decimal Library code, we use only 282980 bytes. This means
that the Intel Decimal Library code uses 60.2% of the total code space. Being
able to move further requires a rather radical rethinking of the project, where
we replace the Intel Decimal Library with size-optimized decimal code.
As a result, release 0.6.0 introduces a new table-free and variable-precision
implementation of decimal computations. In this release, most operations are
implemented, but some features are still missing (e.g. Gamma function). This
release will be simultaneous with 0.5.2, which is functionally equivalent but
still uses the Intel Decimal library. The new implementation is much more
compact, allowing us to return to normal optimizations for the DM42 and regain
some of the lost performance. On the other hand, having to switch to a table
free implementation means that it's significantly slower than the Intel Decimal
Library. The upside of course is that you can compute with decimal numbers that
have up to 9999 digits, and a decimal exponent that can be up to 2^60
(1 152 921 504 606 846 976).
**New features**
Variable precision decimal floating point implementation for arithmetic,
trigonometrics, logs, exponential and integer factorial. Other functions may
still return "unimplemented error".
**Bug fixes**
None. If anything, this release introduces bugs in computations and performance
regressions. However, it frees *a lot* of space for further DM42 development.
**Improvements**
The `Precision` setting now sets the number of digits with a granularity of one,
between 3 and 9999. Ideal use of memory is with multiples of 12 digits, e.g. 12,
24 or 36 digits, where decimal packing does not cause lost bits.
Performance on the DM42 is somewhat improved, since it is now possible to return
to a higher level of optimization.
**Regressions**
In addition to lower performance and unimplemented functions, this version no
longer builds a compatible QSPI. This means that returning to the DM42 requires
flashing *both* the QSPI and the PGM file.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This release was a bit longer in coming than earlier ones, because we are about
to reach the limits of what can fit on a DM42. This release uses 711228 bytes
out of the 716800 (99.2%).
Without the Intel Decimal Library code, we use only 282980 bytes. This means
that the Intel Decimal Library code uses 60.2% of the total code space. Being
able to move further requires a rather radical rethinking of the project, where
we replace the Intel Decimal Library with size-optimized decimal code.
As a result, release 0.5.2 will be the last one using the Intel Decimal Library,
and is release in parallel with 0.6.0, which switches to a table-free and
variable-precisions implementation of decimal code that uses much less code
space. The two releases should otherwise be functionally identical
**New features**
* Shift and rotate instructions (#622)
* Add `CompatibleTypes` and `DetsailedTypes` setting to control `Type` results
* Recognize HP-compatible negative values for flags, e.g. `-64 SF` (#625)
* Add settings to control multiline result and stack display (#634)
**Bug fixes**
* Truncate to `WordSize` the small results of binary operations (#624)
* Fix day-of-week shortcut in simulator
* Avoid double-evaluation of immediate commands when there is no help
* Generate an error when selecting base 1 (#628)
* Avoid `Number too big` error on based nunbers
* Correctly garbage-collect menu entries (#630)
* Select default settings that allow solver to find solutions (#627)
* Fix display of decimal numbers (broken by multi-line display)
* Fix rendering of menu entries for `Fix`, `Std`, etc
* Detect non-finite results in arithmetic, e.g. `(-8)^0.3`m (#635, #639)
* Fix range-checking for `Dig` to allow `-1` value
* Accept large values for `Fix`, `Sci` and `Eng` (for variable precision)
* Restore missing last entry in built-in units menu (#638)
* Accept `Hz` and non-primary units as input for `ConvertToUnitPrefix` (#640)
* Fix LEB128 encoding for signed value 64 and similar (#642)
* Do not parse `IfThenElse` as a command
* Do not consider `E` as a digit in decimal numbers (#643)
* Do not parse `min` as a function in units, but as minute (#644)
**Improvements**
* Add `OnesComplement` flag for binary operation (not used yet)
* Add `ComplexResults` (-103) flag (not used yet)
* Accept negative values for `B→R` (according to `WordSize`)
* Add documentation for `STO` and `RCL` accessing flash storage
* Mention `True` and `False` in documentation
* Rename `MaxBigNumBits` to `MaxNumberBits`
* Return HP-compatible values from `Type` function
* Minor optimization of flags implementation
* Catalog auto-completion now suggests all possible spellings (#626)
* Add aliases for `CubeRoot` and `Hypothenuse`
* Align based number promotion rules to HP calculators (#629)
* Expand the range of garbage collector integrity check on simulator
* Show command according to preferences in error messages (#633)
* Avoid crash in `debug_printf` if used before font initialization
* Update performance data in documentation
* Add ability to disable any reference to Intel Decimal Floating-point library
* Simplify C++ notations for safe pointers (`+x` and `operartor bool()`)
* Fix link to old `db48x` project in `README.md`
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Allow the catalog to auto-complete all possible command spellings.
As a side effect, accelerate the parsing of commands.
All spellings are now stored in a static array, `object::spellings`.
This makes it possible to scan the table in both directions, i.e.
from `id` to text for name rendering, or from name to `id` for
parsing. This makes it also simpler to run operations that loop on all
spellings, including building the catalog entries.
Fixes: #626
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Type` command is used in many programs. It is useful to have it
return HP-compatible values, even if the mapping is not entirely
accurate.
This is under control of the `DetailedTypes` / `CompatibleTypes`
settings. When in `CompatibleTypes` mode, an attempt is made to return
a compatible value, which lacks details. When in `DetailedTypes` mode,
the value returned is negative (to distinguish it from HP values) and
is gives precise information about the actual internal representation.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Since DB48X has dedicated truth values, `True` and `False`, the
documentation should mention them.
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
Implement the following instructions:
* `RotateLeft` (`RL`)
* `RotateRight` (`RR`)
* `RotateLeftByte` (`RLB`)
* `RotateRightByte` (`RRB`)
* `ShiftLeft` (`SL`)
* `ShiftRight` (`SR`)
* `ShiftLeftByte` (`SLB`)
* `ShiftRightByte` (`SRB`)
* `ArithmeticShiftRight` (`ASR`)
DB48X adds counted variants of the above, that shift by an amount other than one
or eight.
* `RotateLeftCount` (`RLC`), rotating left several bits
* `RotateRightCount` (`RRC`), rotating right several bits
* `ShiftLeftCount` (`SLC`), shift left several bits
* `ShiftRightCount` (`SRC`), shift right several bits
* `ArithmeticShiftRightCount` (`ASRC`), arithmetic shift right several bits
Also slight rework of the `BasesMenu`.
Fixes: #622
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
`Map` applies an operation on all elements in a list or array. The
operation on the first level of the stack should take one argument and
return a single value.
`Reduce` applies a cumulative pairwise operation on all elements in a
list or array. The operation on the first level of the stack should
take two arguments and combine them into a single value. The result is
the repeated application of that operation to all elements.
`Filter` selects elements in a list of array based on a predicate. The
predicate given on level 1 of the stack takes a value as argument, and
returns a truth values. The resulting list is built with all elements
where the predicate is true.
Fixes: #613
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
`Head` returns the first element of a list, or an `Invalid dimension`
error if the list is empty.
`Tail` returns all but the first element of a list, or an `Invalid
dimension` error if the list is empty.
Also reorganize the `ListMenu` and add a `DataMenu`.
Fixes: #614
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `Min` and `Max` functions compare two elements.
For arrays, they perform an element-by-element comparison.
For lists, they perform a a lexicographic order comparison.
Fixes: #603
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
The `IP` command return the integer part.
The `FP` command return the fractional part.
Fixes: #601
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>