public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: long long vs long
@ 1998-07-24  5:20 Robert.Cross
  0 siblings, 0 replies; 36+ messages in thread
From: Robert.Cross @ 1998-07-24  5:20 UTC (permalink / raw)
  To: gnu-win32

nleroy@norland.com  wrote:

#Technically, it doesn't make sense, at least in the PC world, where
#all processors are <=32bits. 
PICKY_MODE = TRUE
surely not *all* PC processors - what about the Alpha's? I realise that 
they're not really widespread, but they are out there. I suppose you could
also count PowerPC in that vein.
PICKY_MODE = FALSE

#Probably the more pervasive reason, however, is that there exists A
#LOT of code out there which expects sizeof(long)==4.  It's sort-of an
#un-official C standard.  In particular, legacy code dealing with
#networking, etc., is frequently very loaded with such assumptions.
#IIRC, the original CRAY C compiler used a 32-bit long and a 64-bit
#int, just because so much code had this expectation. 
Yes, and just to confuse the issue, the later compilers used 48bit as the
default. Although you could say '-i64' on the command line to promote these 
variables
all to 64bit.

#IMHO: C should have included standard data sizes, as well as it's generic 
types.  It
#would have made many things a lot simpler.
Agreed. Personally I cannot see a problem with :
short = 8bits, int=16bits, long=32bits, (long long = 64 bits)
other than possible problems when Merced et al are around, rumour has it that 
this
is 128bit native? So what would this be - "long long long" perhaps?

Bob Cross.

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-08-04 16:53 dahms
  0 siblings, 0 replies; 36+ messages in thread
From: dahms @ 1998-08-04 16:53 UTC (permalink / raw)
  To: pommnitz; +Cc: gnu-win32, dahms

Hi Joerg, you wrote:

: > Hopefully ISO reserved the char at ((unsigned int)-1) exactly for
: EOF.
: 
: They can't. To do so, this would require assumptions of the internal
: representation of -1.

You're right! I assumed a 32bit charset will only be available on a
newer platform >=32bit, and all those I know are 2'comp integer,
(except for e.g. IEEE floating point, which is signed-magnitude).


Bye, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-08-01  2:01 Joerg Pommnitz
  0 siblings, 0 replies; 36+ messages in thread
From: Joerg Pommnitz @ 1998-08-01  2:01 UTC (permalink / raw)
  To: Gnu-win32, dahms

> Hopefully ISO reserved the char at ((unsigned int)-1) exactly for
EOF.

They can't. To do so, this would require assumptions of the internal
representation of -1.

Regards
	Joerg
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-29 16:23 dahms
  0 siblings, 0 replies; 36+ messages in thread
From: dahms @ 1998-07-29 16:23 UTC (permalink / raw)
  To: raf; +Cc: gnu-win32, dahms

Hi raf, you wrote:

: >With sizeof(char) = sizeof(int) = 1 and looking at K&R II pg. 16,
: >you'd got a problem with getchar() and EOF, if someone invents a
: >32bit charset and assumes to be able to use them all *and* EOF.
: >AFAIK the biggest charsets currently are 16bit (e.g. Unicode),
: >so at the moment you're safe with a 32bit char!
: 
: no, ISO has a 4-byte charset. it's like unicode but
: with separate copies of asian ideographs, one each for
: japanese, korean and chinese.
: 
: if using this charset, EOF would have to be ((long long)-1) :)

Hopefully ISO reserved the char at ((unsigned int)-1) exactly for EOF.


Bye, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-27 18:55 dahms
  0 siblings, 0 replies; 36+ messages in thread
From: dahms @ 1998-07-27 18:55 UTC (permalink / raw)
  To: donadio; +Cc: gnu-win32, dahms

Hi Matt, you wrote:

: Not to be picky, but to quote K&R II pg. 36:
[snip]

: Also, chars are not limited to be only 8 bits, but they must be at least
: 8 bits.  I routinely work on processors (C40, C44) where CHAR_BIT is
: 32.  This results in the pecularity that
: 
: 	sizeof(char) = sizeof(long) = 1
: 
: which is perfectly legal.  I think there is a lot more code in the world
: that asumes that CHAR_BIT is 8 than sizeof(long) is 4.

With sizeof(char) = sizeof(int) = 1 and looking at K&R II pg. 16,
you'd got a problem with getchar() and EOF, if someone invents a
32bit charset and assumes to be able to use them all *and* EOF.
AFAIK the biggest charsets currently are 16bit (e.g. Unicode),
so at the moment you're safe with a 32bit char!


Bye, Heribert (dahms@ifk20.mach.uni-karlsruhe.de)
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-24 12:58 Earnie Boyd
  0 siblings, 0 replies; 36+ messages in thread
From: Earnie Boyd @ 1998-07-24 12:58 UTC (permalink / raw)
  To: gw32, sjm

---sjm  wrote:
>
> 
> Earnie Boyd writes:
>  > Or why not set a new standard something like
>  > 
>  > int8, int16, int32, int64 to indicate the number of bits.
> 
> Right! The ambiguity of variable sizes has been the most unportable
feature of
> C. I know why they did it but it is still a pain. In those days the
world
> hadn't decided whether word sizes would be a multiple of 6 or 8 bits.
> Implementing a 32 bit data type on an 18 bit (or 24 bit) machine
would have
> been a disaster. Some machines would have wanted int6, int12, int18
and int24
> as bacic integer sizes. It was better to leave word sizes ambiguous
and accept
> the portability problem.
> 

If the compiler were to recognize the number following the `int' as
the number of bits to be used then one could specify whatever they
wished.  This would lend itself to `no problem' when porting assuming
the compiler could recognize this format.

BTW, IMHO, short should be the sizeof(int)/2 and long should be
sizeof(int)*2.

==
-        \\||//
---o0O0--Earnie--0O0o----
--earnie_boyd@yahoo.com--
------ooo0O--O0ooo-------



_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* RE: long long vs long
@ 1998-07-23 11:42 Martin Portmann
  0 siblings, 0 replies; 36+ messages in thread
From: Martin Portmann @ 1998-07-23 11:42 UTC (permalink / raw)
  To: gnu-win32

   That's why portable code use some typedefs that will be 
   redefined according to the CPU/OS.

   -----------------------------------------------------
   Martin Portmann               Mobile +41 79 330 60 12
   Software Department            Phone +41 62 896 42 40 
   Graph-Tech AG, Switzerland          map@graph-tech.ch
            http://www.graph-tech.ch/english/people/map/



> -----Original Message-----
> From:	michael@weiser.saale-net.de [SMTP:michael@weiser.saale-net.de]
> Sent:	Wednesday, July 22, 1998 9:20 PM
> To:	gnu-win32@cygnus.com
> Subject:	Re: long long vs long
> 
> Hi Graham,
> 
> You wrote:
> 
> >This is probably a silly question, but rather than having long long
> for
> >64 bit, why was long not made 64bit? The standard (AFAIK) states that
> >short <= int <= long.  So, it should be possible for long to be 64
> bit
> >rather than 32. This would give a simple progression from 8bit chars
> to
> >64bit longs.
> No because the standard says
> short == 16 bit
> long  == 32 bit
> int   == 16 or 32 depending on the machine's architecture
> 
> For example: Under DOS int is 16 bit while under Win32 und UN*X it is
> 32 bit.
> So there's no way for long to be 64 bit while conforming to the
> standard.
> 
> bye
> 
> Michael
> -
> For help on using this list (especially unsubscribing), send a message
> to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-23 11:42 sjm
  0 siblings, 0 replies; 36+ messages in thread
From: sjm @ 1998-07-23 11:42 UTC (permalink / raw)
  To: gw32

Earnie Boyd writes:
 > Or why not set a new standard something like
 > 
 > int8, int16, int32, int64 to indicate the number of bits.

Right! The ambiguity of variable sizes has been the most unportable feature of
C. I know why they did it but it is still a pain. In those days the world
hadn't decided whether word sizes would be a multiple of 6 or 8 bits.
Implementing a 32 bit data type on an 18 bit (or 24 bit) machine would have
been a disaster. Some machines would have wanted int6, int12, int18 and int24
as bacic integer sizes. It was better to leave word sizes ambiguous and accept
the portability problem.

Did you ever wonder why octal was so popular and why many C constants were
originally only defineable as octal? Octal makes sense in an environment with
word sizes of multiples of 3 bits. Hex is only useful with multiples of 4
bits.

For those who don't remember, early DEC and IBM machines were 6 bit based. For
example the PDP-8 has a 12 bit word size. The IBM 360 was 36 bits. Radix 6
character encoding was quit popular on such machines.

Even worse, many processors only supported one word size. For example special
code needed to be emitted to access bytes on the 16 bit Nova machines. There
were no byte instructions; a lot of shifting and masking. That is what "int"
was for. It was intended to be the native "fast" data type that could be
accessed with single instructions. On a 16 bit machine a 32 bit word was
accessed as two words and implemented as multiple word arithmetic. Of course
that is how "long long" is implemented on most machines today.

Now that bytes have become a defacto standard for word size multiple and
variable word size inctructions exist everywhere one would think C could move
forward. Then again maybe intel is going to jump from variable 64 to a fixed
96 bits for the p96 generation.

Steve Morris
sjm@judgement.com
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-22 17:12 John Estabrook
  0 siblings, 0 replies; 36+ messages in thread
From: John Estabrook @ 1998-07-22 17:12 UTC (permalink / raw)
  To: gnu-win32

It would have caused a lot of grief for people who have a lot of 
code to maintain...  all the sudden a long is not 4 bytes, and a 
long isn't the same size as a pointer.  

Just recompiling your applications could render your old data files 
unreadable because people do things like read in sizeof(long) bytes.
When the files were written a long was 32 bits, if a long was changed 
to 64 then it wouldn't work.

They are tackling the 64-bit long in 64-bit compilers for 64-bit OS's.
If for whatever reason you feel the need to port an app from a 
32-bit compiler to a 64-bit compiler then you have to go back and 
work on your code to remove trouble spots.

As an aside, look at the kind of trouble people run into by C++ 
defining a bool as an integer, and C not having a bool.   Many times 
a bool was typedef'd as a char in old C code.  Now you can get 
situations where a structure containing a bool has a different size 
in C than in C++.  There's so much legacy code out there that you 
really have to be careful when messing with the old order of things.

There are links that discusses these issues if you are interested:

http://www.rdg.opengroup.org/public/tech/aspen/lp64_wp.htm
http://www.sun.com/software/events/presentations/SPG3.Goyal/SPG3.Goyal.html
http://www.unix-systems.org/version2/whatsnew/datasize.html


> Graham Murray said:
> > 
> > This is probably a silly question, but rather than having long long for
> > 64 bit, why was long not made 64bit? The standard (AFAIK) states that
> > short <= int <= long.  So, it should be possible for long to be 64 bit
> > rather than 32. This would give a simple progression from 8bit chars to
> > 64bit longs.
> 

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: long long vs long
@ 1998-07-22 10:06 Earnie Boyd
  1998-07-23  0:43 ` $Bill Luebkert
  0 siblings, 1 reply; 36+ messages in thread
From: Earnie Boyd @ 1998-07-22 10:06 UTC (permalink / raw)
  To: gw32

Or why not set a new standard something like

int8, int16, int32, int64 to indicate the number of bits.


---Graham Murray  wrote:
>
> This is probably a silly question, but rather than having long long
for
> 64 bit, why was long not made 64bit? The standard (AFAIK) states that
> short <= int <= long.  So, it should be possible for long to be 64 bit
> rather than 32. This would give a simple progression from 8bit chars
to
> 64bit longs.
> -
> For help on using this list (especially unsubscribing), send a
message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 

==
-        \\||//
---o0O0--Earnie--0O0o----
--earnie_boyd@yahoo.com--
------ooo0O--O0ooo-------



_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
* long long vs long
@ 1998-07-21  1:55 Graham Murray
  1998-07-22  6:17 ` Harry Broomhall
                   ` (4 more replies)
  0 siblings, 5 replies; 36+ messages in thread
From: Graham Murray @ 1998-07-21  1:55 UTC (permalink / raw)
  To: 'gnu-win32@cygnus.com'

This is probably a silly question, but rather than having long long for
64 bit, why was long not made 64bit? The standard (AFAIK) states that
short <= int <= long.  So, it should be possible for long to be 64 bit
rather than 32. This would give a simple progression from 8bit chars to
64bit longs.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 36+ messages in thread
[parent not found: <Michael>]

end of thread, other threads:[~1998-08-04 16:53 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-07-24  5:20 long long vs long Robert.Cross
  -- strict thread matches above, loose matches on Subject: below --
1998-08-04 16:53 dahms
1998-08-01  2:01 Joerg Pommnitz
1998-07-29 16:23 dahms
1998-07-27 18:55 dahms
1998-07-24 12:58 Earnie Boyd
1998-07-23 11:42 Martin Portmann
1998-07-23 11:42 sjm
1998-07-22 17:12 John Estabrook
1998-07-22 10:06 Earnie Boyd
1998-07-23  0:43 ` $Bill Luebkert
1998-07-21  1:55 Graham Murray
1998-07-22  6:17 ` Harry Broomhall
1998-07-22 13:57 ` Michael H. Warfield
1998-07-23  6:15   ` Harry Broomhall
1998-07-23 13:02   ` Matthew Donadio
1998-07-23 15:30   ` Timothy Writer
1998-07-24 12:58     ` Matthew Donadio
1998-07-25  0:08     ` Larry Hall
1998-07-25  1:22       ` Timothy Writer
1998-07-24 12:58   ` Benjamin Riefenstahl
1998-07-22 13:57 ` Nicholas R LeRoy
1998-07-22 16:50 ` Michael Weiser
1998-07-23  8:33   ` Brian Osman
1998-07-27 14:23     ` Michael Weiser
1998-07-23  8:33   ` Harry Broomhall
1998-07-23 19:01     ` Michael Weiser
1998-07-24  5:20       ` Harry Broomhall
1998-07-25  0:08         ` Mumit Khan
1998-07-26  9:27           ` sjm
     [not found]           ` <9807261625.AA18550.cygnus.gnu-win32@frodo>
1998-07-28  0:57             ` Christopher G. Faylor
1998-07-27 14:23         ` Michael Weiser
1998-07-25  1:22       ` Timothy Writer
1998-07-28  0:57         ` Michael Weiser
1998-07-24  0:25     ` massimo morara
1998-07-22 17:12 ` Andrew Sharp
     [not found] <Michael>
     [not found] ` <H.>
     [not found]   ` <Warfield"'s>
     [not found]     ` <message>
     [not found]       ` <of>
     [not found]         ` <"Wed,>
     [not found]           ` <22>
     [not found]             ` <Jul>
     [not found]               ` <1998>
     [not found]                 ` <11:08:42>
     [not found]                   ` <-0400>

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).