| Author |
Range of Octals
|
Richa Sharma
Ranch Hand
Joined: Dec 06, 2008
Posts: 47
|
|
What is the max numbers i can store as octal. Is it the same as 32 bit integers unsigned?
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Richa Sharma wrote:
Is it the same as 32 bit integers unsigned?
Java dosen't support unsigned int types !
Richa Sharma wrote:
What is the max numbers i can store as octal.
This is the range for 32 bit int
–2,147,483,648 to 2,147,483,647
So you can see, the maximum int type is 2,147,483,647(decimal) and convert it into Octal
|
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
|
 |
Richa Sharma
Ranch Hand
Joined: Dec 06, 2008
Posts: 47
|
|
|
Thanks Sagar
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
Richa Sharma wrote:Thanks Sagar
You're welcome
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
Octal is not a data type - it is just a different way to write down numbers, just like decimal and hexadecimal.
Data types have a range, for 32-bit integers the range is -2^31 to 2^31 - 1, which is:
-2147483648 to 2147483647 (decimal)
-020000000000 to 017777777777 (octal)
-0x80000000 to 0x7FFFFFFF (hexadecimal)
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Sanjay Singhaniya
Greenhorn
Joined: Feb 21, 2009
Posts: 25
|
|
As Jesper Young correctly pointed out, you can represnt integer or long numbers in octal.
To represent a long number in octal; simply add L at the end of number literal.
For example,
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16687
|
|
Interestingly, these two assignments are actually legal in java...
This is because octal (and hex) were historically used for bit masks -- that Java allows you to actually assign all the bits, including the negative bit, as if it was an unsigned number.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Richa Sharma
Ranch Hand
Joined: Dec 06, 2008
Posts: 47
|
|
|
Thanks a lot Guys
|
 |
 |
|
|
subject: Range of Octals
|
|
|