Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > printf parameter type wrangling

Reply
Thread Tools

printf parameter type wrangling

 
 
Zoran Cutura
Guest
Posts: n/a
 
      08-23-2005
Pramod Subramanyan <(E-Mail Removed)> wrote:
>
> Keith Thompson wrote:
>> "Pramod Subramanyan" <(E-Mail Removed)> writes:
>> > Richard Tobin <(E-Mail Removed)> writes:
>> >> In any case, it's not usually wise to rely on knowing the size of
>> >> the datatypes. Especially if you're wrong about it:
>> >> Long is 32 bits on most 32-bit processors.
>> >
>> > Its 64 bits on Intel based platforms, which form the biggest chunk of
>> > the market by a LONG (pun unintended) margin, hence the "most". Anyway,
>> > won't a sizeof solve that problem as well?

>>
>> Type long is 32 bits in every implementation I've see for 32-bit Intel
>> platforms. I've seen 64-bit longs on 64-bit Intel platforms. (Type
>> long long is, of course, required to be at least 64 bits.)

>
> VC++, BC++, LCC and a whole bunch of other platforms on Win32 have 64
> bit longs. Given that Intel has something like 85% of the PC-Processor
> market, and Windows is used on 80% of those, I stick to my stand. [I
> may be wrong about the exact numbers, but they're certainly in the same
> region.] And may I add that you haven't seen too many implementations?


When I compile the following little prog with VSC++ 6.0

#include <limits.h>
#include <stdio.h>

int main(void)
{

printf("bits in char == %d\n", CHAR_BIT);
printf("size of long == %d\n", (int)sizeof(long));
return 0;
}

I get the follwing output:

bits in char == 8
size of long == 4

Which tells me, that long has 4 * 8 Bits which according to Adam Riese would be
32. But I may be wrong.

>
> Moreover, the whole concept 32/64bit processors is ambiguous. What are
> you talking about? Data bus widths, register sizes, memory addressing
> capability, or instruction pointer (or program counter if you like)
> widths? Simply calling a processor 32bit or a platform 64bit does not
> give any real information.


You where talking about the size of longs, wheren't you? I suppose that
even on 64 Bit-Architectures longs may be 32 bits wide.

--
Z ((E-Mail Removed))
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
 
Reply With Quote
 
 
 
 
Flash Gordon
Guest
Posts: n/a
 
      08-23-2005
Pramod Subramanyan wrote:
> Keith Thompson wrote:
>
>>"Pramod Subramanyan" <(E-Mail Removed)> writes:
>>
>>>Richard Tobin <(E-Mail Removed)> writes:
>>>
>>>>In any case, it's not usually wise to rely on knowing the size of
>>>>the datatypes. Especially if you're wrong about it:
>>>>Long is 32 bits on most 32-bit processors.
>>>
>>>Its 64 bits on Intel based platforms, which form the biggest chunk of
>>>the market by a LONG (pun unintended) margin, hence the "most". Anyway,
>>>won't a sizeof solve that problem as well?

>>
>>Type long is 32 bits in every implementation I've see for 32-bit Intel
>>platforms. I've seen 64-bit longs on 64-bit Intel platforms. (Type
>>long long is, of course, required to be at least 64 bits.)

>
> VC++, BC++, LCC and a whole bunch of other platforms on Win32 have 64
> bit longs.


I can't comment on BC++ or LCC, but you are wrong about VC++. I know
because I have it installed. To quote from the Fundamental Types page of
the help:

| Sizes of Fundamental Types
|
| Type Size
| bool 1 byte
| char, unsigned char, signed char 1 byte
| short, unsigned short 2 bytes
| int, unsigned int 4 bytes __intn 1, 2, 4, or 8
| bytes depending on the value of
| n. __intn is Microsoft-specific.
| long, unsigned long 4 bytes
| float 4 bytes
| double 8 bytes
| long double(1) 8 bytes
| long long Equivalent to __int64.
|
| (1) The representation of long double and double is identical.
| However, long double and double are separate types.

So unless you are claiming the CHAR_BIT is something other than 8, long
is definitely 32 bits.

> Given that Intel has something like 85% of the PC-Processor
> market, and Windows is used on 80% of those, I stick to my stand. [I
> may be wrong about the exact numbers, but they're certainly in the same
> region.] And may I add that you haven't seen too many implementations?


I would not be surprised if Keith has seen rather more implementations
that you.

> Moreover, the whole concept 32/64bit processors is ambiguous. What are
> you talking about? Data bus widths, register sizes, memory addressing
> capability, or instruction pointer (or program counter if you like)
> widths? Simply calling a processor 32bit or a platform 64bit does not
> give any real information.


Since it was Intel processors that were referred to, the most probable
definition is whether Intel claim them to be 32 or 64 bit processors.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
 
Reply With Quote
 
 
 
 
Richard Tobin
Guest
Posts: n/a
 
      08-23-2005
In article <(E-Mail Removed) .com>,
Pramod Subramanyan <(E-Mail Removed)> wrote:

>> That doesn't help much, because you have to know which function to call.

>
>1) I've heard of an operator called sizeof.


The original poster seemed to want a single function call that worked
for all built-in types. Your proposal didn't do that. If you can fix
it up using sizeof, that might be useful.

The rest of your post consists of insults and a factual error which
others have corrected, so I will not address it.

-- Richard
 
Reply With Quote
 
Pramod Subramanyan
Guest
Posts: n/a
 
      08-24-2005
Sorry, I got this wrong.

Richard, I apologize for the patronizing tone.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      08-24-2005
"Pramod Subramanyan" <(E-Mail Removed)> writes:
> Sorry, I got this wrong.
>
> Richard, I apologize for the patronizing tone.


Since Pramod didn't provide context, I'll mention that what he got
wrong was his claim that type long is commonly 64 bits on 32-bit Intel
platforms.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      08-24-2005
"Pramod Subramanyan" <(E-Mail Removed)> wrote:

> Sorry, I got this wrong.
>
> Richard, I apologize for the patronizing tone.


Got _what_ wrong? _What_ patronising tone? I don't recall you being
patronising to me... oh, wait, maybe you were patronising to Mr.
Heathfield?

It _is_ possible to get Google Groups Broken Beta to quote, you know.

Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
printf affects following printf/s azza C Programming 0 10-17-2010 09:43 AM
Extracting printf(...) from (void) printf(....) guru Perl Misc 8 02-03-2009 10:37 PM
(void) printf vs printf whatluo C Programming 29 09-08-2005 05:42 PM
How do I write a function that accepts a 'printf' type parameter? winbatch C++ 5 02-15-2005 04:34 AM
bus error with printf line included, error without printf line? ben C Programming 4 06-26-2004 04:42 PM



Advertisments