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


Groups > comp.arch > #32024

Re: ones complement, was Between

From Terje Mathisen <terje.mathisen@tmsw.no>
Newsgroups comp.arch
Subject Re: ones complement, was Between
Date 2015-12-20 17:47 +0100
Organization Aioe.org NNTP Server
Message-ID <n56m2p$ubn$1@speranza.aioe.org> (permalink)
References (9 earlier) <2b740e11-8eaa-488d-a3a0-f73533a7073f@googlegroups.com> <n4mfp0$2bq$1@speranza.aioe.org> <829ac3c0-69b5-4ca7-ad19-925e472efb60@googlegroups.com> <n4mu22$6do$1@speranza.aioe.org> <c8108207-ea80-410f-9573-9686cf6cc416@googlegroups.com>

Show all headers | View raw


already5chosen@yahoo.com wrote:
> On Monday, December 14, 2015 at 7:25:27 PM UTC+2, Terje Mathisen
>> I'm from the 'C integers are badly broken, so don't ever use them
>> unless you absolutely have to' school.
>>
>> I have very seldom seen integer code that wouldn't work
>> better/faster/more portably using unsigned instead.
>>
>
> It's not the first time you are saying that. But I'd prefer more
> elaborate explanation, because without explanation it simply does not
> make sense to me. To me it seems rather obvious that see 'int' type
> is much closer to people's intuitive (well, not really intuitive,
> let's say tough in school. from practical perspective it's the same
> as intuitive) perception of the number. For example, it is very
> non-intuitive when (a-b<c) does not follow from (a < b+c). It is very
> non-intuitive when we can't code a loop as "for (i = n; i >= 0; --i)
> ..."

Decrementing counted loops are one of the uglier cases, I write those 
either offset by one or (if I know that n will be positive) as a do while.

>
> You can say that even for 'int' (a-b<c) is not an exact equivalent of
> (a < b+c). That's true theoretically, but not in practice, because in
> practice numbers with magnitude > 2**30 are very rare.

Very rare errors like that is a perfect conduit for hacks and cracks. :-(

>
>> When I do need integers then it would be nice if I could have a
>> user-level trap to catch overflows and automatically convert the
>> result to a bigint style extended/arbitrary precision variable
>> instead.
>
> As Bruce said, that's only possible in "dynamically-typed" languages.
> And when we are already in "dynamic" land, I am not sure that
> overflow trap is the best way to achieve the desired effect even
> under assumption that user-level exceptions are fast. I don't have
> opinion of my own, because I don't know enough about implementation
> options for such languages. Intuitively I think that overflow trap
> can be the best option from performance perspective in [most common]
> situation when overflow is extremely rare. But when it comes to
> performance, even well trained programmer's intuition sucks badly;
> untrained intuition, like mine, probably sucks even worse.

"Always measure, never assume" - Mike Abrash

I believe my intuition re the actual performance of a given algorithm is 
probably better than most, but as you say, most programmers suck badly. :-(

It is only after I have written a complete implementation myself, either 
in asm or low-level C (i.e. using C as a portable assembler), that I get 
a real feel for how long it should take.

Scaling is actually easier since I automatically think in Big-O 
notation. :-)

Terje

-- 
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"

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


Thread

Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-07 20:13 -0800
  Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-08 01:50 -0800
    Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-08 04:19 -0800
      Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-08 04:57 -0800
        Re: Between CISC and RISC algrant109@gmail.com - 2015-12-11 12:57 -0800
          Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-11 13:44 -0800
          Re: Between CISC and RISC Ivan Godard <ivan@millcomputing.com> - 2015-12-11 15:40 -0800
            Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-11 21:13 -0800
              Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-12 04:14 -0800
                Re: Between CISC and RISC already5chosen@yahoo.com - 2015-12-12 12:59 -0800
            Re: Between CISC and RISC algrant109@gmail.com - 2015-12-14 08:44 -0800
        Re: Between CISC and RISC Exophase <exophase@gmail.com> - 2015-12-15 13:23 -0800
          Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-16 02:13 -0800
  Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-08 04:17 -0800
    Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-09 05:35 -0800
      Re: Between CISC and RISC jacko <jackokring@gmail.com> - 2015-12-09 08:56 -0800
      Re: Between CISC and RISC Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-12-09 10:30 -0800
        Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-09 11:06 -0800
          Re: Between CISC and RISC Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-12-09 12:17 -0800
            Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-09 12:56 -0800
              Re: Between CISC and RISC Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-12-10 11:44 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-10 22:50 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-10 23:06 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-11 06:01 -0800
        Re: Between CISC and RISC David W Schroth <davidschroth@harrietmanor.com> - 2015-12-10 21:37 -0600
        Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-11 10:37 -0800
          Re: Between CISC and RISC Stephen Fuld <SFuld@alumni.cmu.edu.invalid> - 2015-12-11 15:19 -0800
            Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-11 21:20 -0800
            Re: Between CISC and RISC David W Schroth <davidschroth@harrietmanor.com> - 2015-12-12 18:22 -0600
        Re: Between CISC and RISC anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-12 23:20 +0000
          Re: Between CISC and RISC Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-13 07:48 +0100
            Re: Between CISC and RISC anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-13 18:00 +0000
              Re: Between CISC and RISC Ivan Godard <ivan@millcomputing.com> - 2015-12-13 11:37 -0800
              Re: Between CISC and RISC Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-13 21:57 +0100
          Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-13 07:19 -0800
            Re: ones complement, was Between John Levine <johnl@iecc.com> - 2015-12-13 15:32 +0000
              Re: ones complement, was Between Quadibloc <jsavard@ecn.ab.ca> - 2015-12-13 08:32 -0800
                Re: ones complement, was Between John Levine <johnl@iecc.com> - 2015-12-13 16:52 +0000
                Re: ones complement, was Between Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-13 08:56 -0800
                Re: ones complement, was Between John Levine <johnl@iecc.com> - 2015-12-13 17:03 +0000
                Re: ones complement, was Between Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2015-12-13 10:12 -0700
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-13 21:51 +0100
                Re: ones complement, was Between Jan Coombs <jan_coombs@murmic.plus.com> - 2015-12-13 22:18 +0000
              Re: ones complement, was Between MitchAlsup <MitchAlsup@aol.com> - 2015-12-13 10:15 -0800
                Re: ones complement, was Between Megol <golem960@gmail.com> - 2015-12-13 12:18 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-13 22:00 +0100
                Re: ones complement, was Between Ivan Godard <ivan@millcomputing.com> - 2015-12-13 13:07 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-14 10:15 +0100
                Re: ones complement, was Between Ivan Godard <ivan@millcomputing.com> - 2015-12-14 01:39 -0800
                Re: ones complement, was Between already5chosen@yahoo.com - 2015-12-14 01:59 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-14 14:21 +0100
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-14 14:21 +0000
                Re: ones complement, was Between already5chosen@yahoo.com - 2015-12-14 07:03 -0800
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-14 15:50 +0000
                Re: ones complement, was Between MitchAlsup <MitchAlsup@aol.com> - 2015-12-14 16:34 -0800
                Re: ones complement, was Between Ivan Godard <ivan@millcomputing.com> - 2015-12-14 18:42 -0800
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-15 09:13 +0000
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-15 09:25 +0000
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-15 08:53 +0000
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-14 18:25 +0100
                Re: ones complement, was Between Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-15 02:20 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-15 11:58 +0100
                Re: ones complement, was Between already5chosen@yahoo.com - 2015-12-20 02:45 -0800
                Re: ones complement, was Between already5chosen@yahoo.com - 2015-12-20 03:11 -0800
                Re: ones complement, was Between nj_kruse@me.com (Niels Jørgen Kruse) - 2015-12-20 14:34 +0100
                Re: ones complement, was Between already5chosen@yahoo.com - 2015-12-20 05:57 -0800
                Re: ones complement, was Between MitchAlsup <MitchAlsup@aol.com> - 2015-12-20 12:12 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-21 15:33 +0100
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-21 14:58 +0000
                Re: ones complement, was Between Quadibloc <jsavard@ecn.ab.ca> - 2015-12-21 10:06 -0800
                Re: ones complement, was Between MitchAlsup <MitchAlsup@aol.com> - 2015-12-21 15:48 -0800
                Re: ones complement, was Between Ivan Godard <ivan@millcomputing.com> - 2015-12-21 17:13 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-20 17:47 +0100
                Re: ones complement, was Between jacko <jackokring@gmail.com> - 2015-12-20 10:09 -0800
                Re: ones complement, was Between Jean-Marc Bourguet <jm@bourguet.org> - 2015-12-20 20:09 +0100
                Re: ones complement, was Between Chris Gray <cg@GraySage.COM> - 2015-12-20 11:02 -0700
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-21 14:11 +0000
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-21 16:08 +0100
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-21 16:03 +0000
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-21 16:18 +0000
                Re: ones complement, was Between nmm@wheeler.UUCP (Nick Maclaren) - 2015-12-21 17:53 +0000
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-21 21:29 +0100
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-21 15:57 +0000
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-21 21:25 +0100
                Re: ones complement, was Between John Levine <johnl@iecc.com> - 2015-12-14 02:11 +0000
                Re: ones complement, was Between Quadibloc <jsavard@ecn.ab.ca> - 2015-12-14 00:27 -0800
                Re: ones complement, was Between Quadibloc <jsavard@ecn.ab.ca> - 2015-12-13 17:16 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-14 10:20 +0100
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-14 10:29 +0000
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-14 12:17 +0000
                Re: ones complement, was Between MitchAlsup <MitchAlsup@aol.com> - 2015-12-14 06:40 -0800
                Re: ones complement, was Between Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-14 14:26 +0100
                Re: ones complement, was Between anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-14 08:09 +0000
          Re: Between CISC and RISC mrs@kithrup.com (Mike Stump) - 2015-12-14 00:11 +0000
      Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2015-12-09 17:30 -0800
    Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-14 00:17 -0800
      Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-14 05:48 -0800
  Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-15 15:32 -0800
    Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-21 12:57 -0800
      Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-21 19:00 -0800
        Re: Between CISC and RISC Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-22 10:26 +0100
          Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-22 06:39 -0800
          Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-23 10:17 -0800
            Re: Between CISC and RISC Jean-Marc Bourguet <jm@bourguet.org> - 2015-12-23 19:55 +0100
              Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-23 17:15 -0800
                Re: Between CISC and RISC Terje Mathisen <terje.mathisen@tmsw.no> - 2015-12-24 10:27 +0100
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 04:50 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 07:37 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 09:47 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 11:47 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 12:48 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 18:56 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-25 09:34 -0800
                Re: Between CISC and RISC anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-12-25 17:57 +0000
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-25 10:42 -0800
                Re: Between CISC and RISC Bruce Hoult <bruce.hoult@gmail.com> - 2015-12-26 03:29 -0800
                Re: Between CISC and RISC Jakob Brundin <jakbru@gmail.com> - 2015-12-26 07:23 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-26 09:54 -0800
                Re: Between CISC and RISC Anne & Lynn Wheeler <lynn@garlic.com> - 2015-12-26 16:18 -0800
                Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2016-01-31 10:17 -0800
                Re: Between CISC and RISC paul wallich <pw@panix.com> - 2016-01-31 13:39 -0500
                Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2016-01-31 19:16 -0800
                Re: Between CISC and RISC anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-02-01 12:43 +0000
                Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2016-02-01 06:44 -0800
                Re: Between CISC and RISC Ivan Godard <ivan@millcomputing.com> - 2015-12-24 13:03 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-24 16:35 -0800
                Re: Between CISC and RISC Ivan Godard <ivan@millcomputing.com> - 2015-12-24 16:45 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2016-01-31 07:14 -0800
                Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2015-12-25 07:21 -0800
                Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-25 07:39 -0800
                Re: Between CISC and RISC George Neuner <gneuner2@comcast.net> - 2015-12-25 11:53 -0500
                Re: Between CISC and RISC MitchAlsup <MitchAlsup@aol.com> - 2016-01-31 10:10 -0800
                Re: Between CISC and RISC Robert Wessel <robertwessel2@yahoo.com> - 2016-01-31 23:34 -0600
          Re: Between CISC and RISC Quadibloc <jsavard@ecn.ab.ca> - 2015-12-26 10:07 -0800

csiph-web