Topic: [Q] creating a 64bit unsigned integer
Author: sirwillard@my-deja.com
Date: 2000/09/23 Raw View
In article <8q9vee$emk$1@wanadoo.fr>,
"Gabriel Biberian" <dagab@mac.com> wrote:
> I need to use 64 bit unsigned integers in my program. is there a
standard
> c++ way to create an unsigned 64bit int (in winc++ i use __int64 and
in
> linux __int64_t)?
>
> i tried unsigned double (which is 64bit on my compilers) but it won't
let
> me.
>
> i'd like to avoid using int or character arrays to do this. also, in
what
> kind of variable would you store a 1024bit RSA key?
As others have said, there is nothing in standard C++ for this. You're
best off using a typedef for a platform specific type that you know is
64 bits. However, if a platform doesn't have a type that's 64 bits you
can always emulate one with a class. There was a recent submission to
Boost for a bitint<> template that allowed you to specify an "integer
type" of a specified number of bits. If you join the Boost e-mail
group at http://www.egroups.com you can find this in the files section.
--
William E. Kempf
Software Engineer, MS Windows Programmer
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Ron Natalie <ron@sensor.com>
Date: 2000/09/20 Raw View
Gabriel Biberian wrote:
>
> I need to use 64 bit unsigned integers in my program. is there a standard
> c++ way to create an unsigned 64bit int (in winc++ i use __int64 and in
> linux __int64_t)?
NO
> i tried unsigned double (which is 64bit on my compilers) but it won't let
> me.
unsigned doesn't go with double (right up there with my "short long' concept when
we needed another type on a 64 bit machine, we finally settled for mediums).
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: llewelly.@@edevnull.dot.com
Date: 2000/09/21 Raw View
"Gabriel Biberian" <dagab@mac.com> writes:
> I need to use 64 bit unsigned integers in my program. is there a standard
> c++ way to create an unsigned 64bit int (in winc++ i use __int64 and in
> linux __int64_t)?
>
> i tried unsigned double (which is 64bit on my compilers) but it won't let
> me.
>
> i'd like to avoid using int or character arrays to do this. also, in what
> kind of variable would you store a 1024bit RSA key?
[snip]
There are no C++ types that are guaranteed to be 64 bits.
Many unix compilers support 'unsigned long long', which is usually 64
bits, but that is not a part of standard C++ (though it is now a
part of standard C99.)
I expect that many C++ compilers will soon support __int64_t and
friends, as they are part of C99, but they are not standard C++ .
I suggest that you not use any of these types directly; use a
typedef.
For 1024 bit unsigned, implement a concrete type to represent it -
say, a class containing an array of 128 unsigned chars, with
appropriate operations.
Note that if you just need to *store* a 1024bit key, and you do not
need to *do* anything with it, your class will need few operations.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: fjh@cs.mu.OZ.AU (Fergus Henderson)
Date: 2000/09/21 Raw View
llewelly.@@edevnull.dot.com writes:
>I expect that many C++ compilers will soon support __int64_t and
> friends, as they are part of C99, but they are not standard C++ .
`int64_t' is part of C99, but `__int64_t' is not.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Gabriel Biberian" <dagab@mac.com>
Date: 2000/09/20 Raw View
I need to use 64 bit unsigned integers in my program. is there a standard
c++ way to create an unsigned 64bit int (in winc++ i use __int64 and in
linux __int64_t)?
i tried unsigned double (which is 64bit on my compilers) but it won't let
me.
i'd like to avoid using int or character arrays to do this. also, in what
kind of variable would you store a 1024bit RSA key?
thanks,
gabriel biberian
======================================= MODERATOR'S COMMENT:
This post covers multiple issues, not all of which are related to the C++ Standard. Please keep replies on-topic for comp.std.c++.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Jim Fischer" <jfischer@calpoly.edu>
Date: 2000/09/20 Raw View
"Gabriel Biberian" <dagab@mac.com> wrote in message
news:8q9vee$emk$1@wanadoo.fr...
> I need to use 64 bit unsigned integers in my program. is there a standard
> c++ way to create an unsigned 64bit int
Nope.
> i'd like to avoid using int or character arrays to do this. also, in what
> kind of variable would you store a 1024bit RSA key?
Probably some sort of array (e.g., a char array).
Jim
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Stewart Rosenberger" <foogle@adelphia.net>
Date: 2000/09/20 Raw View
If I were going to store a RSA key like that, I'd put it in an array of 128
chars... I guess for efficiency, you could put it in an array 32 ints (on a
32-bit platform).
There's no *standard* way of producing a specific bit-length integer, given
any different platform.
-----------------------------
Stewart Rosenberger
"Gabriel Biberian" <dagab@mac.com> wrote in message
news:8q9vee$emk$1@wanadoo.fr...
> I need to use 64 bit unsigned integers in my program. is there a standard
> c++ way to create an unsigned 64bit int (in winc++ i use __int64 and in
> linux __int64_t)?
>
> i tried unsigned double (which is 64bit on my compilers) but it won't let
> me.
>
> i'd like to avoid using int or character arrays to do this. also, in what
> kind of variable would you store a 1024bit RSA key?
>
> thanks,
>
> gabriel biberian
>
>
>
> ======================================= MODERATOR'S COMMENT:
> This post covers multiple issues, not all of which are related to the C++
Standard. Please keep replies on-topic for comp.std.c++.
>
>
> ---
> [ comp.std.c++ is moderated. To submit articles, try just posting with ]
> [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
> [ --- Please see the FAQ before posting. --- ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]