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


Groups > comp.programming > #6086

Re: Here is why C++ and C are bad...

From Richard Heathfield <rjh@cpax.org.uk>
Newsgroups comp.programming
Subject Re: Here is why C++ and C are bad...
Date 2015-12-30 17:39 +0000
Organization A noiseless patient Spider
Message-ID <n614nj$p08$1@dont-email.me> (permalink)
References (4 earlier) <n6063m$ccb$1@dont-email.me> <n60m14$lf$1@dont-email.me> <87h9j06ip1.fsf@bsb.me.uk> <n610v9$afu$1@dont-email.me> <n613i4$jca$3@dont-email.me>

Show all headers | View raw


On 30/12/15 17:19, David Brown wrote:

<snip>

> You didn't get as far as Python, I take it.

No. I would in any case have chosen PHP for my 'P' language, but from 
what you say below it seems that Python would have been the more 
interesting choice.

> In Python, the integer
> types just get as big as you need (until you run out of time or memory).
>   So to a large extent you can assume your integers really are
> mathematical integers, and add them as much as you want.  (So "unsigned"
> integers don't really exist.)

What if I wanted to construct a candidate for a large prime? The usual 
way to do this is to pick a number of bits, set the top and bottom bits, 
and then arbitrarily assign other bits (either setting or clearing them, 
as dictated by some entropy source). Then one applies Miller-Rabin a few 
times, and adds 2 if any of the tests fail. Traditionally one uses an 
array of unsigned char for this, but if you don't /have/ unsigned char, 
or indeed any unsigned type, presumably you could still do this with 
code such as:

candidate = 1 << (bitcount - 1);
candidate |= 1;
for i = 1 to bitcount - 2
   candidate |= getrandomnumber(0,1) << i;

?

(I realise I'm moving away from signed/unsigned here!)

-- 
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 20:31 +0000
  Re: Here is why C++ and C are bad... Kaz Kylheku <kaz@kylheku.com> - 2015-12-29 21:20 +0000
  Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-29 23:13 +0100
    Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-29 22:19 +0000
      Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 09:56 +0100
        Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 13:28 +0000
          Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 14:55 +0100
            Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 16:32 +0000
              Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:17 +0100
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:01 +0000
          Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 15:48 +0000
            Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 16:35 +0000
              Re: Here is why C++ and C are bad... David Brown <david.brown@hesbynett.no> - 2015-12-30 18:19 +0100
                Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 17:39 +0000
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 20:26 +0000
              Re: Here is why C++ and C are bad... "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> - 2015-12-30 18:32 +0100
              Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 19:55 +0000
                Re: Here is why C++ and C are bad... Richard Heathfield <rjh@cpax.org.uk> - 2015-12-30 20:15 +0000
                Re: Here is why C++ and C are bad... Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-12-30 22:00 +0000
      Re: Here is why C++ and C are bad... Ian Collins <ian-news@hotmail.com> - 2015-12-31 10:16 +1300

csiph-web