fabien van mook

all packages "fvm-*"

package "fvm-real2text"

function file "real2text_simplify.m"

Function rt = real2text_simplify(rt)

returns the struct after the insertion of 
powers-of-ten to be printed. These powers-of-ten
are chosen so that they appear simply and easily
to read by humans. The simplification is done
based on the data produced by function 
real2text_decompose().

The input struct rt must have the following fields:
  rt.realtype   (vector of integers classifying each 
                 element in rt.data with 
                 value 0 for a non-real,
                 value 1 for a finite real, and
                 values 2...5 for non-finite reals 
                 -Inf, +Inf, NaN and NA, respectively)
  rt.precision  (string with the sprintf-template, 
                 or integer >= 0)
  rt.decomp.mnt (one-dimensional cell-array of strings 
                 consisting of the sign and mantissa)
  rt.decomp.pot (one-dimensional cell-array of signed 
                 integers indicating the power-of-ten 
                 of the first digit in the mantissa)
  rt.decomp.nsd (one-dimensional cell-array of integers 
                 indicating the number of significant 
                 digits, i.e. length(rt.decomp.mnt{k}) - 1)

The input struct rt may have the following optional 
fields:
  rt.engineering (boolean whether reals are printed with
                  a power-of-ten of k*3, with k = 
                  {..., -2, -1, 0, 1, 2, ...}; true at
                  default)
  rt.simplify (boolean whether simplification of the 
               total series of reals is tried 
               depending on a minimal fraction of reals
               that can be printed in a certain way;
               true at default)
  rt.eight  (minimal fraction of reals which can be
             printed as "dddd.dddd" at simplification;
             0.7 at default)
  rt.six    (minimal fraction of reals which can be
             printed as "ddd.ddd" at simplification;
             0.5 at default)
  rt.one    (factor multiplied to rt.eight or rt.six 
             for printing "dddd.dddd" or "ddd.ddd", 
             respectively, with a power-of-ten of zero;
             0.6 at default)
  rt.debug  (boolean whether to print some information
             on the internals of the function; false 
             at default)

The output struc rt contains new or renewed fields:
  rt.pot_show   (one-dimensional cell-array of signed 
                 integers indicating the power-of-ten, 
                 to be printed)

If rt.precision > 0, or it contains a string, the 
precision is "defined", and (insignificant) trailing
zeros will not be printed.

If rt.precision does not contain a string and if
rt.precision == 0, the precision is "undefined"
or "infinite", and (insignificant) trailing zeros
may be printed to obtain a simple and easy to read
appearance.


(c) 2026 fabien van mook

2026.08.20 release of this file within package "fvm-real2text" under GNU GPLv3+