[integer] Implementing long long and others

As I understand the integer.hpp does not support types over 32 bits at present. I used this library in my work and I had to implement long long type. I suppose it is not too hard to implement other needed integer types (like _int64, _int128 on Microsoft and Intel compilers) using types from boost/cstdint.hpp file. But it requires slight redesign of library (integer.hpp) and it may requires to introduce a recursion (not too deep). I would like to implement this if it interests somebody. Also I think user may get understandable error reports through dummy types like struct too_much_bits_error; or struct negative_number_of_bits_error; with no body. Best regards. Igor Mikushkin

Igor Mikushkin wrote:
As I understand the integer.hpp does not support types over 32 bits at present.
Not true -- where'd you get that idea?
I used this library in my work and I had to implement long long type.
I suppose it is not too hard to implement other needed integer types (like _int64, _int128 on Microsoft and Intel compilers) using types from boost/cstdint.hpp file.
You can use the following: boost::int64_t boost::uint64_t I use these and date-time and they are well defined everywhere. Jeff

2007/12/24, Jeff Garland <jeff@crystalclearsoftware.com>:
Igor Mikushkin wrote:
As I understand the integer.hpp does not support types over 32 bits at present.
Not true -- where'd you get that idea?
From integer.hpp file :) I have boost 1.33.1, but if you go to boost site -> documentation -> integer -> integer.hpp you will see.
I suppose it is not too hard to implement other needed integer types (like _int64, _int128 on Microsoft and Intel compilers) using types from boost/cstdint.hpp file.
You can use the following:
boost::int64_t boost::uint64_t
I use these and date-time and they are well defined everywhere.
Yes, it is well defined, but my program is very templated and I rely on syntax like int_t <some_number> :: type; Igor Mikushkin

Igor Mikushkin wrote:
2007/12/24, Jeff Garland <jeff@crystalclearsoftware.com>:
Igor Mikushkin wrote:
As I understand the integer.hpp does not support types over 32 bits at present. Not true -- where'd you get that idea?
From integer.hpp file :) I have boost 1.33.1, but if you go to boost site -> documentation -> integer -> integer.hpp you will see.
Ok, this looks like it could be improved.
I suppose it is not too hard to implement other needed integer types (like _int64, _int128 on Microsoft and Intel compilers) using types from boost/cstdint.hpp file. You can use the following:
boost::int64_t boost::uint64_t
I use these and date-time and they are well defined everywhere.
Yes, it is well defined, but my program is very templated and I rely on syntax like int_t <some_number> :: type;
What I meant is that these are defined on all platforms. So will these not work for you? Jeff

2007/12/24, Jeff Garland <jeff@crystalclearsoftware.com>:
Igor Mikushkin wrote: Yes, it is well defined, but my program is very templated and I rely on syntax like int_t <some_number> :: type;
What I meant is that these are defined on all platforms. So will these not work for you?
It works great but not for me :) Because I need templated syntax provided by integer.hpp. There are other ways of course but this syntax does exactly what I need. Igor

Sorry if I post this mail twice but it looks like previous mail disappeared 2007/12/24, Jeff Garland <jeff@crystalclearsoftware.com>:
Igor Mikushkin wrote: Yes, it is well defined, but my program is very templated and I rely on syntax like int_t <some_number> :: type;
What I meant is that these are defined on all platforms. So will these not work for you?
It works great but not for me :) Because I need templated syntax provided by integer.hpp. There are other ways of course but this syntax does exactly what I need. Igor

Igor Mikushkin wrote:
As I understand the integer.hpp does not support types over 32 bits at present.
I used this library in my work and I had to implement long long type.
There's a ticket on this issue: http://svn.boost.org/trac/boost/ticket/653 I would also appreciate having long long supported by integer.hpp. -- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center

Jeff Garland wrote:
Igor Mikushkin wrote:
As I understand the integer.hpp does not support types over 32 bits at present.
Not true -- where'd you get that idea?
Just checked and it's not there in boost/integer.hpp: FYI this has come up before and it's never been fixed, really should be too, so patches would be welcome I guess? John.

2007/12/24, Igor Mikushkin <igor.mikushkin@gmail.com>:
I suppose it is not too hard to implement other needed integer types (like _int64, _int128 on Microsoft and Intel compilers) using types from boost/cstdint.hpp file.
Sorry, there are no __int128 type. I suppose the subject can be done in this way namespace boost { namespace { template <int X> struct int_helper { typedef typename int_helper <X + 1> :: type type; }; template <> struct int_helper < sizeof (int8) > { typedef int8 type; }; template <> struct int_helper < sizeof (int16) > { typedef int16 type; }; template <> struct int_helper < sizeof (int32) > { typedef int32 type; }; #ifndef BOOST_NO_INT64 template <> struct int_helper < sizeof (int64) > { typedef int64 type; }; #endif } template <int X> struct int_t { typedef typename int_helper <(X - 1) / 8 + 1> :: type type; }; };
participants (4)
-
Igor Mikushkin
-
Jeff Garland
-
John Maddock
-
Niels Dekker - mail address until 2008-12-31