are there systems where int is unsigned

F

Fabian Wein

Hi,

my question is limited to moderm and powerfull architectures (we do
simulation and solve large systems of linear equations).

Are there any architectures arround where an int is unsigned? I have in
my mind that this is not defined by the standard - right?

I also found no list which gives the types for different architectures/
compilers.

Thanks,

Fabian
 
V

Victor Bazarov

Fabian said:
my question is limited to moderm and powerfull architectures (we do
simulation and solve large systems of linear equations).

Are there any architectures arround where an int is unsigned? I have
in my mind that this is not defined by the standard - right?

What is not defined? That 'int' is signed? Yes, it *is* defined.
The "int" is one of the four "signed integer types" (3.9.1/2).
I also found no list which gives the types for different
architectures/ compilers.

Not sure what you're looking for and why. Care to rephrase?

V
 
F

Fabian Wein

Hi Victor,
What is not defined? That 'int' is signed? Yes, it *is* defined.
The "int" is one of the four "signed integer types" (3.9.1/2).
thanks for answer!
Not sure what you're looking for and why. Care to rephrase?

In our project all types are wrapped, so we have

typedef Double double;
typedef Complex std::complex<double>;
typedef Int ...
typedef UInt ...

I doubt that this makes sense but on the other side I don't know
what an "int" is on - let's say

Opteron with gcc
Itanium with icc
ppc with ???

Now I know for sure that "int" is not unsigned - thanks :)

I guess double is fixed to 64 bits?

BTW, what is a good online ressource? I normally use cppreference.com

Fabian
 
V

Victor Bazarov

Fabian said:
Hi Victor,

In our project all types are wrapped, so we have

typedef Double double;

You mean, reversed, no doubt:

typedef double Double;
typedef Complex std::complex<double>;

typedef std::complex said:
typedef Int ...

Presuming

typedef ... Int;

, what's there in the "..."?
typedef UInt ...

I doubt that this makes sense

Unless you can explain, I am not going to guess.
but on the other side I don't know
what an "int" is on - let's say

Opteron with gcc
Itanium with icc
ppc with ???

Quoting the Standard: "Plain ints have the natural size suggested
by the architecture of the execution environment". IOW, 'int' is
for signed integer arithmetic and it's the best choice for it, no
matter where your program is running.

You can learn its size in bytes by using 'sizeof'. You can learn
its size in bits by multiplying the size in bytes by CHAR_BITS.
You can learn other properties from 'std::numeric_limits<int>'.

If you need some kind of abstraction layer between your arithmetic
operations in your C++ code and the underlying system providing
the actual implemenation, it might make sense. For examle, CGAL
folks have several numeric engines implemented (including the plain
ol' FP types).
Now I know for sure that "int" is not unsigned - thanks :)

I guess double is fixed to 64 bits?

No, it isn't.
BTW, what is a good online ressource? I normally use cppreference.com

I use www.google.com.

V
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

I guess double is fixed to 64 bits?

Nope, but you might be interested in the defines in <cfloat>, the
closes you can come to the number of bits of a double seems to be the
number of bits in the mantissa: DBL_MANT_DIG.
BTW, what is a good online ressource? I normally use cppreference.com

A copy of the standard is nice, if you don't want to buy one you can
use a draft of the standard, google for WG21, first hit, click on
papers and look around. Try to find a draft from just before or after
it was standardized and you should be close enough on most things.

www.cplusplus.com/reference/ might also be of interest, mainly for the
IO-part of the library.
 
V

Victor Bazarov

Erik said:
Nope, but you might be interested in the defines in <cfloat>, the
closes you can come to the number of bits of a double seems to be the
number of bits in the mantissa: DBL_MANT_DIG.

Or see 'std::numeric_limits said:
A copy of the standard is nice, if you don't want to buy one you can
use a draft of the standard, google for WG21, first hit, click on
papers and look around. Try to find a draft from just before or after
it was standardized and you should be close enough on most things.

www.cplusplus.com/reference/ might also be of interest, mainly for the
IO-part of the library.

Usually nothing beats the documentation that comes with your compiler,
unless it's one of those "free" compilers. Unfortunately, the Standard
only can tell you how something *should* be implemented, and it's not
always the way it's implemented in your compiler.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top