473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

number of bytes for a type in C++

In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.

Please advise. Thanks

Jul 22 '05 #1
6 2424
I believe that the standard guarantees minimum ranges for intrinsic
types. For example, I believe that the minimum range for type int is
[-32768, +32767].

Regards,

Jon Trauntvein

Jul 22 '05 #2
jr********@hotmail.com wrote:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


You think right.
Jul 22 '05 #3
It is depending upon the hardware.

According to TCPPPL,
this is what guaranteed about the sizes of fundamental types

1 = sizeof(char) <= sizeof(short) <= sizeof(int) <=sizeof(long)
1<= sizeof(bool) <= sizeof(long)
sizeof(char) <=sizeof(wchar_t) <= sizeof(long)
sizeof(float) <= sizeof(double) <= sizeof(long double)
sizeof(N) = sizeof(signed N) = sizeof(unsigned N)

Jul 22 '05 #4
On 10 Dec 2004 09:07:28 -0800, in comp.lang.c , pv**********@gmail.com
wrote:
It is depending upon the hardware.


And the compiler. Think about old DOS compilers.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 22 '05 #5
jr********@hotmail.com writes:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


In C, it's dependent on the implementation, with some specific
constraints imposed by the standard.

But since your question is about C++, cross-posting it to comp.lang.c
was a bad idea.

Followups redirected.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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.
Jul 22 '05 #6
Keith Thompson wrote:
jr********@hotmail.com writes:
In C++, the amount of memory used to store int is 4 bytes, or dependent
upon the hardware?
I think still dependent on the machine, since C++ compiler is platform
dependent.


In C, it's dependent on the implementation, with some specific
constraints imposed by the standard.


The same is true for C++. The rules regarding integer type sizes are the
same in C++ as in C, with the exception that C++ doesn't know the "long
long" type.

Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Gavin | last post by:
Hi, I'm a newbie to programming of any kind. I have posted this to other groups in a hope to get a response from anyone. Can any one tell me how to make my VB program read the Bios serial number...
5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
122
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
12
by: george r smith | last post by:
Greetings, What is the C# code that returns the number of bytes in a string such as 32313131353131333432317E547E3132357E5553447E467E3536363031303030343835323632 7E307E56 It should be 80 I...
1
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
4
by: sumedh..... | last post by:
In a compiler there are 36bits for a word and to store a character 8bits are needed. In this to store a character two words appended. Then for storing k characters string,how many words are needed?
25
by: Daniel Kraft | last post by:
Hi, I do need to implement something similar to C++'s std::bitset in C; for this, I use an array of int's to get together any desired number of bits, possibly larger than 32/64 or anything like...
58
by: sh.vipin | last post by:
is there any way to find out number of bytes freed on a particular free() call in C
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.