Talk:Long integer

Latest comment: 14 years ago by Kaiserkarl13 in topic What

MySQL Server data types

edit

These details about MySQL Server data types have been removed from this article as they are not relevant. The information about data sizes in general is already available on other pages (e.g. Integer (computer science)) --HappyDog 23:29, 28 Oct 2004 (UTC)

Microsoft SQL Server 2000 has the following sizes of integer data types:
bigint
Has a length of 8 bytes and stores numbers from
–2^63 (-9,223,372,036,854,775,808) through 2^63-1 (9,223,372,036,854,775,807).
integer or int
Has a length of 4 bytes, and stores numbers from -2,147,483,648 through 2,147,483,647.
smallint
Has a length of 2 bytes, and stores numbers from -32,768 through 32,767.
tinyint
Has a length of 1 byte, and stores numbers from 0 through 255.

stub?

edit

Does this page merit a computing-related stub notice? To me, computer science is related to computers, but I'm not a programmer or anyone else who deals with the subject. However, the main article quotes Edsger Dijkstra that it's "no more about computers than astronomy is about telescopes." --Theaterfreak64 23:57, Feb 7, 2005 (UTC)

The purpose of using a specific stub notice is to help people knowledgeable in a field find stubs that they may be able to work on, so yes I think it would be very appropriate here. If there were separate stub notices about 'computer science' and 'computers' then I think dijkstra's famous quote would apply, but in this context the distinction is not relevant. --HappyDog 00:36, 8 Feb 2005 (UTC)

What

edit

Is a long not 8 bytes? This page gives the impression that it's 4, but a standard integer is 4 bytes. - Ferret 21:47, 29 June 2006 (UTC)Reply

I think this page might be fucked, unless the standard definition of long is different from Java's. This page here: (http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Long.html) says a long ranges from -263 to 263-1. The wiki says it goes from -231 to 231-1. This range is more consistent with a regular old int: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html

What gives? Sean Gray 08:51, 2 November 2006 (UTC)Reply

Who said a long needs to be the same for all architecutres and/or languages. j.engelh 22:31, 1 December 2006 (UTC)Reply

Indeed. Please read the first sentence: "In computer science, a long integer is a variable that can hold a positive or negative whole number whose range is greater or equal to that of a standard integer on the same machine." --HappyDog 17:48, 2 December 2006 (UTC)Reply
Reality said so. Long integer is a starndard, and standards are what allow computers and the internet as we know them to function. Furthermore, in the .NET Framework, COM/COM+, SQL Server, Oracle, MySql, MS Access, and indeed the Windows Kernal itself, a long integer is eight bytes, while a standard integer is four. DigitalEnthusiast 21:02, 18 December 2006 (UTC)Reply
The short answer to Sean Gray's question is that, yes, in C and C++ at least, the standard definition of long is different from Java's. —Steve Summit (talk) 13:46, 21 April 2010 (UTC)Reply

The ANSI C standard only requires that sizeof(short) <= sizeof(int) <= sizeof(long) (also that sizeof(float) <= sizeof(double) <= sizeof(long double)). I think it's also required that sizeof(int) be equal to the word size of the machine. In C (and C++) compilers for UNIX-like 32-bit operating systems, this is usually translated to ints and longs being the same size, or 4 bytes. As far as I know, the same is true on 64-bit UNIX-like OS's: sizeof(int) = sizeof(long) = 8 bytes. It may not make the most sense in the world (why have a separate type if it's the same size?!?), but that's definitely the way it is everywhere I've bothered to look. On a side note: I remember using Windows back in the stone age (1994 or so), when (16-bit) Windows 3.1 was still in widespread use. If I recall correctly, sizeof(short) and sizeof(int) were the same there (16 bits, or 2 bytes), and sizeof(long) was 4 bytes. I could be remembering incorrectly, however. Kaiserkarl13 (talk) 20:55, 29 June 2010 (UTC)Reply

Int32 redirect

edit

Int32 redirects here. 32 bits / 8 bits-per-byte = four bytes, not eight. DigitalEnthusiast 21:05, 18 December 2006 (UTC)Reply

DigitalEnthusiast, it's time to live up to your name and research computer numbering formats... :-) --HappyDog 02:03, 19 December 2006 (UTC)Reply
You're right about VBA and older versions of VB ( standalone ), but the fact remains that Int32 shouldn't redirect to this page. It's a specific .net data type, and 8-bytes of storage. Int64 is the .net version of what's described here.
You might be right. Then again, these terms may be used in other contexts where they have different definitions. Either way, there is room for confusion. I think they should probably both redirect to integer, or perhaps a list of data types (if there is a standalone list) but I can't say that with any certainty. Does anyone else have any thoughts on this? --HappyDog 21:59, 20 December 2006 (UTC)Reply

"long long" existence

edit

If a source becomes required for the issue of "long long" not existing in ISO C++ this proposal to add it could be used: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf . It discusses the history in the introduction. Nitwit005 (talk) 08:09, 12 November 2008 (UTC)Reply

16 bits???

edit

I just slapped a "citation needed" tag on the first row of the table, for the alleged 16 bit version of Visual C++. Microsoft has done some strange things in the past; but I can't believe anyone would ever define long to be 16 bits in any C-like language. —Steve Summit (talk) 22:25, 20 April 2010 (UTC)Reply

The C/C++ standards don't mandate that integers be of any minimum size, only that progressively larger types are greater than or *equal* in size to their predecessors (eg: sizeof(long) >= sizeof(int) >= sizeof(short) >= sizeof(char)); An 8-bit architectures may have an 8-bit long, in other words. Furthermore, the 'long' data type does not even warrant a full page on Wikipedia - sorry! I think we should merge the relevant stuff here into their respective programming language articles and then request that this one be deleted. Sebastian Garth (talk) 15:35, 21 April 2010 (UTC)Reply
I don't have a strong opinion on whether this article should or shouldn't exist, but to your first point, you're quite mistaken. C and C++ have always specified minimum ranges for the integral types, which imply that char is at least 8 bits, short and int are at least 16, long is at least 32, and (for newer revisions of the standards) long long is at least 64. (See any good reference on C.) —Steve Summit (talk) 16:20, 21 April 2010 (UTC)Reply
Don't know about the ancient versions of VC++, but the minimum size of long is 32 bits, as can be inferred from limits.h. The expression char buf[sizeof(long) == 1]; is well-formed if and only if char is at least 32 bits. decltype (talk) 17:23, 21 April 2010 (UTC)Reply
The most recent 16-bit version of VC++ (1.52) had 32-bit longs, I have removed the entry. decltype (talk) 18:23, 21 April 2010 (UTC)Reply
Even the pre-C++ versions of Microsoft C for the PC had 32 bit longs. However, I wouldn't be at all surprised if some of the really antediluvian versions of C (for the Apple 2 for instance) had 16 bit longs. But they may not have supported long types at all. Is it legal to say [citation needed] on a talk page? - Richfife (talk) 20:47, 21 April 2010 (UTC)Reply
no one has popped up with references that far i can see. the best guess ive found myself that far is this one [1] - no idea how trustworthy that is but it declares "long int" as beeing a 32 bit signed value. less relevant but probably nice to know is the opinion that some embedded c compilers might not care for the standard and use lesser bits even for "long", e.g. 16 bit only ([2]). some language overview can be found here: [3] - it puts the C++ long into the 4 byte line. Some bits on compiler compatiblity history and other not-that-true assumptions can be found here: [4] - but could not locate hints on 2 byte long there. the only google hit for "sizeof(long int) == 2" is a single piece of code written for a systematic search on an unknown platform style. a nice image on the topic of the type portability mess is there: [5] Even a short history on MS C compilers did not provide too much of a hint [6]. - PERIOD - no real hint on any sort of selected size in early microsoft compilers - but if size were different then it would be more likely that people had talked about that. if that type was not present then less fuzz, but even for that there is no indication. present conclusion: no citation available that proves either the 16 or the 32 bit case. no citation available that proves the pure existence of that type. no citation available that provides the tech specs on the compiler version in question or any similar compiler version. -> that former statement without sufficient citation and thus dropped for good reasons at present. there is no source thus its "open" to any good future findings a computer historian might ever bring to light. (other sources just show how difficult it is to only get the right lines from the "C" standard, and how easy people will get tricked by thinking its only about "int" and drop the "long" in front of it.) --Alexander.stohr (talk) 19:41, 4 May 2010 (UTC)Reply
I do have a reference, namely the documentation for VC++ 1.52. Since the reference disproved the claim, I removed it from the article. decltype (talk) 05:56, 6 May 2010 (UTC)Reply
You have inspired me, and I have found my Microsoft C/C++ 7.00 for MS-DOS docs which also say that 'long' is 32 bits (that is before Visual C++). That's pretty obvious really. I'm sure there are embedded systems for which 'long' is 16 bits, but the claim about Visual C++ was incorrect because even the earliest Microsoft C compiler (from Lattice C I believe) had 32-bit longs (a trivial thing to achieve on x86). Johnuniq (talk) 07:25, 6 May 2010 (UTC)Reply
I was able to establish that Aztec C for the 6502 used 32 bit longs. In general, though, I'm kind of allergic to using specific bit counts in text that is not specific to a particular compiler. For instance, the "long long" sentence that mentions that they're usually 64 bits. This is one of those red pill / blue pill perfect correctness vs. likelihood to be useful questions, though. - Richfife (talk) 16:42, 10 May 2010 (UTC)Reply

Byte count of long long in C

edit

The C standard does not mandate a minimum byte count of long nor long long, only that sizeof(long long)≥sizeof(long)≥sizeof(int) and that the magnitude of the maximum/minimum values are possible to be represented. 22:27, 3 September 2010 (UTC) —Preceding unsigned comment added by Drakeneld (talkcontribs)