Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #4637

Re: literals for an int128 class

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: literals for an int128 class
Date Wed, 04 May 2011 08:53:34 +1200
Lines 27
Message-ID <92b8aeFj03U13@mid.individual.net> (permalink)
References <8ec2c079-9c65-462a-a4b2-af8f2f0422ce@p7g2000yqd.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net x3jVglBEO1nKGT2IR+V47g4Eba+LCbvCp6QFuRN1Ey7gQ12mUW
Cancel-Lock sha1:9ihMc+UCdPSbMKA+ZL4BAr7Qtmg=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <8ec2c079-9c65-462a-a4b2-af8f2f0422ce@p7g2000yqd.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:4637

Show key headers only | View raw


On 05/ 4/11 08:39 AM, cps wrote:
> I am considering writing an int128 class as a programming exercise.
> Before I start (and I have a fair idea of how to do it) I was
> wondering what I can do about literals and the assignment operator.  I
> would like to be able to use integer literals with the assignment and
> other operators with literals that are sized at 128 bits.
>
> E.g. I'd like to be able to do:
>
>       uint128 myInt128 = 184467440737095516160;
>
>
>       Note that the foregoing literal would produce an error (correctly
> so) if I attempted to assign it to an uint64 because it is (2^64) *
> 10.
>
>       Is there any way I can set it up to deal with large literals?
>
>      Or am I going to have to use strings and parse them?

The only way a system could have 128 bit literals would be if it had a 
128 bit type!

You'll have to settle for strings.

-- 
Ian Collins

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

literals for an int128 class cps <chrissusie8@gmail.com> - 2011-05-03 13:39 -0700
  Re: literals for an int128 class Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-03 16:51 -0400
  Re: literals for an int128 class Ian Collins <ian-news@hotmail.com> - 2011-05-04 08:53 +1200
  Re: literals for an int128 class Pete Becker <pete@versatilecoding.com> - 2011-05-03 17:17 -0400
  Re: literals for an int128 class Michael Doubez <michael.doubez@free.fr> - 2011-05-04 01:38 -0700
    Re: literals for an int128 class Ian Collins <ian-news@hotmail.com> - 2011-05-04 21:15 +1200
      Re: literals for an int128 class Michael Doubez <michael.doubez@free.fr> - 2011-05-06 01:03 -0700
        Re: literals for an int128 class Pete Becker <pete@versatilecoding.com> - 2011-05-06 08:00 -0400
          Re: literals for an int128 class Victor Bazarov <v.bazarov@comcast.invalid> - 2011-05-06 09:30 -0400
          Re: literals for an int128 class Michael Doubez <michael.doubez@free.fr> - 2011-05-06 08:00 -0700

csiph-web