are there systems where int is unsigned

Discussion in 'C++' started by Fabian Wein, Mar 1, 2007.

  1. Fabian Wein

    Fabian Wein Guest

    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
    Fabian Wein, Mar 1, 2007
    #1
    1. Advertising

  2. Fabian Wein wrote:
    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Mar 1, 2007
    #2
    1. Advertising

  3. Fabian Wein

    Fabian Wein Guest

    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!

    >> 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?


    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
    Fabian Wein, Mar 1, 2007
    #3
  4. Fabian Wein wrote:
    > 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!

    >
    >>> 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?

    >
    > 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<double> Complex;

    > 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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Mar 1, 2007
    #4
  5. On Mar 1, 3:43 pm, Fabian Wein <-technik.uni-erlangen.de>
    wrote:
    > 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.

    --
    Erik Wikström
    =?iso-8859-1?q?Erik_Wikstr=F6m?=, Mar 1, 2007
    #5
  6. Erik Wikström wrote:
    > On Mar 1, 3:43 pm, Fabian Wein <-technik.uni-erlangen.de>
    > wrote:
    >> 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.


    Or see 'std::numeric_limits<double>' members.

    >> 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.


    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
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Mar 1, 2007
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timo Freiberger
    Replies:
    3
    Views:
    941
    Bob Hairgrove
    Oct 30, 2004
  2. Schnoffos
    Replies:
    2
    Views:
    1,206
    Martien Verbruggen
    Jun 27, 2003
  3. er
    Replies:
    6
    Views:
    486
    Andre Kostur
    Sep 14, 2007
  4. ciccio

    int*unsigned int = unsigned?

    ciccio, Jun 4, 2010, in forum: C++
    Replies:
    2
    Views:
    403
    Öö Tiib
    Jun 4, 2010
  5. pozz
    Replies:
    12
    Views:
    731
    Tim Rentsch
    Mar 20, 2011
Loading...

Share This Page