5 Replies - 871 Views - Last Post: 04 October 2012 - 04:28 AM Rate Topic: -----

#1 coderguy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-September 11

Is integer index the same with c++ and java

Posted 02 October 2012 - 06:39 PM

Hello to all

Out of curiosity I was wondering is integer range index the same with c++ and Java or is it limited to OS or Architecture.

Also would minimum/negative range be considered 0 - 2147483647 and maximum be considered 2147483648 - 4294967295

Thanks in advance
Is This A Good Question/Topic? 0
  • +

Replies To: Is integer index the same with c++ and java

#2 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3798
  • View blog
  • Posts: 13,755
  • Joined: 08-August 08

Re: Is integer index the same with c++ and java

Posted 02 October 2012 - 06:53 PM

That depends on your compiler. Generally, integers are 16, 32, or 64 bits.
http://www.somacon.com/p111.php
Was This Post Helpful? 1
  • +
  • -

#3 coderguy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-September 11

Re: Is integer index the same with c++ and java

Posted 02 October 2012 - 07:48 PM

View PostCTphpnwb, on 02 October 2012 - 06:53 PM, said:

That depends on your compiler. Generally, integers are 16, 32, or 64 bits.
http://www.somacon.com/p111.php


Thanks for the reply

Question:
So a compiler interpreting a 32 bit integer would have minimum/negative range of 0 - 2147483647 and maximum 2147483648 - 4294967295
or is it the other way around.

Im basing this on 16 possible combinations on 8 individual bits bits
Was This Post Helpful? 0
  • +
  • -

#4 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2630
  • View blog
  • Posts: 4,190
  • Joined: 21-June 11

Re: Is integer index the same with c++ and java

Posted 03 October 2012 - 01:49 AM

What do you mean by "minimum range" and "maximum range"? Usually we say that an integral type has a minimum value and a maximum value. An integer's range would go from the minimum to the maximum value. If your definitions differ from that (which obviously they do since otherwise terms like "minimum range" wouldn't make any sense), you should state them explicitly.

Also note that there are signed and unsigned integers. Normal integers (i.e. ones that aren't defined using the unsigned keyword) are signed, so their range includes negative numbers.
Was This Post Helpful? 0
  • +
  • -

#5 jjl   User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

Re: Is integer index the same with c++ and java

Posted 03 October 2012 - 02:10 PM

The smallest amount of memory you can directly access is a byte. All other primitive data types are either greater or equal to that data type; however, on most systems it goes as the following

char - 1 byte
short - 2 bytes
int - 4 bytes (2 bytes on older systems)
long - 4 bytes (used for older systems to guarantee a 4 bytes int)
long long - 8 bytes (if the system permits it)

This C legacy wasn't incorporated into Java. In Java, each type is guaranteed a certain amount of bytes.
Was This Post Helpful? 0
  • +
  • -

#6 sepp2k   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2630
  • View blog
  • Posts: 4,190
  • Joined: 21-June 11

Re: Is integer index the same with c++ and java

Posted 04 October 2012 - 04:28 AM

View Postjjl, on 03 October 2012 - 11:10 PM, said:

long - 4 bytes (used for older systems to guarantee a 4 bytes int)


long is 8 bytes on 64-bit systems at least when using gcc.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1