Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2007, 12:19 AM
Registered User
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Maximum values of int and float data types

Dear all,

The numbers are stored in binary format in any computer language.Both int and float data types have size 4 bytes (32 bits).

If that be the case,why int type variable can store maximum number 2147483647 while float can store up to 3.4028235E38 ? If both data types store numbers in same number of bits (32 bits),ideally maximum number that can be stored should also be same.But that is not the case. Could anybody please let me know why is it so?

Consider the following simple code.

public class MinMax{
    public static void main(String args[]){
        System.out.println(Float.SIZE);
        System.out.println(Float.MAX_VALUE);
        System.out.println();

        System.out.println(Integer.SIZE);
        System.out.println(Integer.MAX_VALUE);
    }
}

The output of the code is as follows

32
3.4028235E38

32
2147483647

Regards,
Vishram

 
Old August 22nd, 2007, 10:30 AM
Authorized User
 
Join Date: May 2007
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

using different patterns for int float

==============

Float.MAX_VALUE
its a static constant in class Float

http://studyjava.org/forums/





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to represent Float data Values r_taduri Crystal Reports 0 July 18th, 2006 07:55 AM
Data Types edward2006 Infopath 0 November 7th, 2005 06:06 PM
Data type change from int to Varchar getxyz SQL Server 2000 1 April 29th, 2005 09:59 AM
Error converting data type varchar to float. Trojan_uk SQL Server ASP 5 April 27th, 2004 02:56 AM
Data Types bph Access VBA 3 January 25th, 2004 05:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.