Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | File Exchange
ATOMS : Floating Point details
Please login or create an account

Floating Point

Functions to manage floating point numbers
(3259 downloads for this version - 10872 downloads for all versions)
A more recent valid version exists: 0.2.2
Michael Baudin
Owner Organization
Consortium Scilab - Digiteo
Allan Cornet
Michael Baudin
Creation Date
November 25, 2010
Source created on
Scilab 5.2.x
Binaries available on
Scilab 5.2.x:
Windows 64-bit Windows 32-bit Linux 64-bit Linux 32-bit MacOSX
Install command
--> atomsInstall("floatingpoint")

The goal of this toolbox is to provide a collection of 
algorithms for floating point number management.
This is more a learning tool than an operationnal component,
although it might complement some features which are not 
provided by Scilab.

The flps_systemgui function allows to see the distribution
of floating point numbers graphically.
By varying the rounding mode, the precision and the logscale,
we can actually the distribution of a toy floating 
point number. Adding or suppressing the denormals can be 
instructive too.

The functions allow to compute automatically the 
properties of the current Scilab system with 
respect to the doubles. It is similar in spirit 
to the number_properties functions, except that 
our functions are based on macros and that 
the returned values are made consistent 
with the references cited in the bibliography.
Moreover, the flps_radix function returns
the current radix and allows to check that the 
current rounding mode is round-to-nearest (which 
is IEEE's default).

The functions allow to create virtual floating point 
systems, which allows to see their discrete nature 
in simplified examples. The rounding mode of 
such a virtual floating point system can be configured
to one of the four mode from the IEEE standard. 
This feature allows to see the effect of the rounding mode
on the distribution of floating point numbers. This is 
not easy to see with a straightforward Scilab, since the 
rounding mode is round-to-nearest, most of the time.


The following is a list of the current functions :

 * Convert
   * flps_Me2sm : Returns the (s,m) representation given (M,e).
   * flps_double2hex : Converts a double into a hexadecimal string.
   * flps_frombary : Returns the floating point number given its b-ary
   * flps_hex2double : Converts a hexadecimal string into its double.
   * flps_sme2M : Returns the integral significand from (s,m,e).
   * flps_tobary : Returns the digits of the b-ary decomposition.
 * Functions
   * flps_chop : Round matrix elements to t significant binary places.
   * flps_frexp : Returns the exponent and fraction.
   * flps_minimumdecimalstr : Returns the minimum string for equality.
   * flps_signbit : Returns the sign bit of x
 * Number
   * flps_number2hex : Converts a floating point number into a hexadecimal
   * flps_numbereval : Returns the value of the current floating point number.
   * flps_numbergetclass : Returns the class of the number;
   * flps_numberisfinite : Returns true if the number is finite.
   * flps_numberisinf : Returns true if the number is an infinity.
   * flps_numberisnan : Returns true if the number is a nan.
   * flps_numberisnormal : Returns true if the number is bnormal.
   * flps_numberissubnormal : Returns true if the number is subnormal.
   * flps_numberiszero : Returns true if the number is zero.
   * flps_numbernew : Returns a new floating point number.
 * Properties
   * flps_emax : Returns the maximum exponent and value before overflow.
   * flps_emin : Returns the minimum exponent and value before underflow.
   * flps_eps : Returns the machine epsilon and the precision for Scilab
   * flps_isIEEE : Returns true if the current system satisfies basic IEEE
   * flps_radix : Compute the radix used for Scilab doubles.
 * System
   * flps_systemall : Returns the list of floating point numbers of the given
floating point system.
   * flps_systemgui : Plots all the numbers in the current floating point
   * flps_systemnew : Returns a new floating point system.


See DLAMCH for a comparison with Lapack's algorithms:

See number_properties in Scilab for a comparison :


Copyright (C) 2010 - DIGITEO - Michael Baudin
Files (4)
[1.85 kB]
Miscellaneous file
[183.92 kB]
Source code archive

[183.92 kB]
Miscellaneous file

[342.54 kB]
OS-independent binary for Scilab 5.2.x
Binary version
Automatically generated by the ATOMS compilation chain

News (0)
Comments (2)     Leave a comment 
Comment from Michael Baudin -- January 24, 2012, 10:46:14 PM    
The v0.2 is correctly packaged.

This is a test on Windows XP 32bits with Scilab 5.3.3.

   TMPDIR = C:\DOCUME~1\Root\LOCALS~1\Temp\SCI_TMP_1732_

   001/030 - [SCI\contrib\floatingpoint\0.2-1] Me2sm...............passed 
   002/030 - [SCI\contrib\floatingpoint\0.2-1] chop................passed 
   003/030 - [SCI\contrib\floatingpoint\0.2-1] datasetread.........failed  : dia and ref 
are not equal 
   004/030 - [SCI\contrib\floatingpoint\0.2-1] double2hex..........passed 
   005/030 - [SCI\contrib\floatingpoint\0.2-1] emax................passed 
   006/030 - [SCI\contrib\floatingpoint\0.2-1] emin................passed 
   007/030 - [SCI\contrib\floatingpoint\0.2-1] eps.................passed
   008/030 - [SCI\contrib\floatingpoint\0.2-1] frexp...............passed 
   009/030 - [SCI\contrib\floatingpoint\0.2-1] frombary............passed 
   010/030 - [SCI\contrib\floatingpoint\0.2-1] hex2double..........passed
   011/030 - [SCI\contrib\floatingpoint\0.2-1] isIEEE..............passed 
   012/030 - [SCI\contrib\floatingpoint\0.2-1] minimumdecimalstr...passed 
   013/030 - [SCI\contrib\floatingpoint\0.2-1] number2hex..........passed 
   014/030 - [SCI\contrib\floatingpoint\0.2-1] numbereval..........passed 
   015/030 - [SCI\contrib\floatingpoint\0.2-1] numbergetclass......passed 
   016/030 - [SCI\contrib\floatingpoint\0.2-1] numberis............passed 
   017/030 - [SCI\contrib\floatingpoint\0.2-1] numberisfinite......passed 
   018/030 - [SCI\contrib\floatingpoint\0.2-1] numberisinf.........passed 
   019/030 - [SCI\contrib\floatingpoint\0.2-1] numberisnan.........passed 
   020/030 - [SCI\contrib\floatingpoint\0.2-1] numberisnormal......passed 
   021/030 - [SCI\contrib\floatingpoint\0.2-1] numberissubnormal...passed 
   022/030 - [SCI\contrib\floatingpoint\0.2-1] numberiszero........passed 
   023/030 - [SCI\contrib\floatingpoint\0.2-1] numbernew...........passed 
   024/030 - [SCI\contrib\floatingpoint\0.2-1] radix...............passed 
   025/030 - [SCI\contrib\floatingpoint\0.2-1] signbit.............passed 
   026/030 - [SCI\contrib\floatingpoint\0.2-1] sme2M...............passed 
   027/030 - [SCI\contrib\floatingpoint\0.2-1] systemall...........passed 
   028/030 - [SCI\contrib\floatingpoint\0.2-1] systemgui...........passed 
   029/030 - [SCI\contrib\floatingpoint\0.2-1] systemnew...........passed 
   030/030 - [SCI\contrib\floatingpoint\0.2-1] tobary..............passed 

The failure of the datasetread unit test is minor and is reported at :
Comment from Michael Baudin -- January 24, 2012, 10:46:44 PM    
Here is the changelog of v0.2.

floatingpoint (0.2)
    * Fixed formatting of subnormals.
    * Added hex2double.
    * Added numbernew("hex",flps,hexstr).
    * Improved startup script.
    * Created separate section for "number" and "system"
    * Reorganized help pages into sections.
    * Created overview and system/number overview.
    * Created number2hex from number/number_bin2hex
    * Used apifun.
    * flps_frexp: changed order of arguments (backward compatibility lost)
    * flps_frombary: changed order of arguments (backward compatibility lost)
    * Added flps_Me2sm
    * Added flps_sme2M
    * Added flps_signbit
    * Updated flps_frexp: fix for x=zero.
    * Added flps_double2hex.
    * Removed flps_format2system : integrated into systemnew for consistency of 
constructor (backward compatibility lost)
    * Removed flps_IEEEsingle : integrated into systemnew for consistency of constructor 
(backward compatibility lost)
    * Removed flps_IEEEdouble : integrated into systemnew for consistency of constructor 
(backward compatibility lost)
    * Removed flps_IEEEdoubleext : integrated into systemnew for consistency of 
constructor (backward compatibility lost)
    * Fixed bug in flps_emax: wrong vmax.
    * Updated flps_emax: added parameter p (backward compatibility lost)
    * Fixed formatting of the largest denormal : not all the bits in the exponent were 
    * Removed flps_numberformat: merged into numbernew("double")  (backward
    * Added support for +/-%inf, +/-0, %nan in formatnew("double").
    * Created isnormal, issubnormal, isinf, isfinite, iszero, getclass.
    * Created minimumdecimalstr to remove unnecessary digits.
Leave a comment
You must register and log in before leaving a comment.
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.