1. Computing
Send to a Friend via Email




A float is a Java data type which can store floating point numbers (i.e., numbers that can have a fractional part). Only 4 bytes are used to store float numbers giving a value range of -3.4028235E+38 to 3.4028235E+38.

A problem with the float (and double) data type is it suffers from rounding errors:

float rounding = 0.9f - 0.11f;

gives the output of:


Use the BigDecimal class for precise calculations.

Note: float data types are not used unless memory is an issue and an application needs to store a lot of fractional numbers. The double is the default data type to use for storing fractional numbers.


# A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Related Video
Create Bullet, Number, and Definition Lists in HTML
Export Data From an Excel Sheet to a Word Document

©2014 About.com. All rights reserved.