Previous topic | Next topic | Ada Home Page | Index

FLOAT type

A FLOAT is a positive or negative number with a decimal part

FLOAT literals: optional sign, digits, period, digits

        123.456         
        1.23456E2
        0.0001234               
        1.234e-4                

Why use floats?

BUT

Range of FLOATs

Attributes

Example:

        PUT ("The number of digits in a float value is: ");
        PUT (FLOAT'DIGITS); NEW_LINE;

        PUT ("The lowest  float value is: ");
        PUT (FLOAT'FIRST); NEW_LINE;

        PUT ("The highest float value is: ");
        PUT (FLOAT'LAST); NEW_LINE;

        PUT ("The tiniest float value is: ");
        PUT (FLOAT'SMALL); NEW_LINE;


        The number of digits in a float value is:  15
        The lowest  float value is: -1.79769313486232E+308
        The highest float value is:  1.79769313486232E+308
        The tiniest float value is:  1.94469227433161E-62

Errors with FLOATs

Since floating point numbers are stored with only a fixed number of significant digits of accuracy, they are subject to rounding errors. Four types of errors arise from this:

Operations on FLOATs

I/O: special library provides GET, PUT

        package float_io is new TEXT_IO.FLOAT_IO( FLOAT );
        use  float_io;

arithmetic

relational:


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 12 Feb 96