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


Groups > comp.lang.c > #43502

Re: Updating C default type

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.lang.c
Subject Re: Updating C default type
Date 2014-04-24 12:05 +0000
Organization Aioe.org NNTP Server
Message-ID <ljauml$uph$1@speranza.aioe.org> (permalink)
References <lj66ho$8fg$1@speranza.aioe.org> <20140422120151.80@kylheku.com> <8e15a84d-76d2-4f8f-ba1e-804998a7bd5e@googlegroups.com> <lj8rak$nov$2@dont-email.me> <27c76700-f5da-45a2-b0c8-d0328c889a5b@googlegroups.com>

Show all headers | View raw


Malcolm McLean <malcolm.mclean5@btinternet.com> wrote:

(snip)
> It's a human tradeoff between precision and range. We usually allocate more
> bits to the mantissa than the exponent, because we seldom need very large or
> very small real values. 

> Generally, if a number is data rather than an index or count, 
> and it's not a special case like RGB values or audio samples, 
> I'll represent it as a double, even if it's inherently integral. 

Reasonably often, I have values that I need to multiply by some 
integer, then divide by another integer, then truncate (as integer
divide naturally does). If the values are big enough, the product
doesn't fit in 32 bits, but I don't trust divide not to round, 
so I prefer (long long) for the intermediate.

Many compilers on 32 bit systems can do that using a 32 bit multiply
(with 64 bit product) and divide a 64 bit value by a 32 bit dividend
using the appropriate divide instruction. 

> IEEE double can represent precisely all
> integers from + to - 9007199254740992 (if I've got my 
> calculations right).
> That's better than a long, unlike long long it's seldom unsupported,
> there isn't the annoying special case of the largest negative value 
> being one greater than the largest positive value, and if you need 
> more than 9 quadrillion, what are you representing? 
> Even Obama's debt isn't that large. 

I might do that for add, subtract, and multiply but not for
divide or modulo.

-- glen

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


Thread

Updating C default type Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2014-04-22 16:48 +0000
  Re: Updating C default type jacob navia <jacob@spamsink.net> - 2014-04-22 18:59 +0200
    Re: Updating C default type Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2014-04-22 17:13 +0000
      Re: Updating C default type Keith Thompson <kst-u@mib.org> - 2014-04-22 11:59 -0700
      Re: Updating C default type Kaz Kylheku <kaz@kylheku.com> - 2014-04-22 19:12 +0000
        Re: Updating C default type jacob navia <jacob@spamsink.net> - 2014-04-25 19:31 +0200
      Re: Updating C default type Stephen Sprunk <stephen@sprunk.org> - 2014-04-22 15:41 -0500
      Re: Updating C default type "BartC" <bc@freeuk.com> - 2014-04-22 21:47 +0100
      Re: Updating C default type Ken Brody <kenbrody@spamcop.net> - 2014-04-24 12:25 -0400
        Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-24 10:32 -0700
        Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-24 20:17 +0000
        Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-24 21:03 +0000
    Re: Updating C default type Gareth Owen <gwowen@gmail.com> - 2014-04-22 19:12 +0100
  Re: Updating C default type Keith Thompson <kst-u@mib.org> - 2014-04-22 10:26 -0700
  Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-22 10:28 -0700
  Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-22 18:20 +0000
    Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-22 19:09 +0000
      Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-04-22 15:35 -0400
        Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-04-22 15:38 -0400
        Re: Updating C default type Kaz Kylheku <kaz@kylheku.com> - 2014-04-22 19:54 +0000
          Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-22 21:27 +0000
            Re: Updating C default type "BartC" <bc@freeuk.com> - 2014-04-22 23:08 +0100
    Re: Updating C default type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-22 22:03 +0100
    Re: Updating C default type Thomas Jahns <jahns@idontlikespam.dkrz.de> - 2014-04-23 09:59 +0200
    Re: Updating C default type David Thompson <dave.thompson2@verizon.net> - 2014-05-25 16:44 -0400
      Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-05-26 05:48 +0000
  Re: Updating C default type "Osmium" <r124c4u102@comcast.net> - 2014-04-22 14:01 -0500
    Re: Updating C default type Quentin Pope <qp19433@hotmail.NOSPAM.com> - 2014-04-23 16:57 +0000
      Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-04-23 13:13 -0400
      Re: Updating C default type Kaz Kylheku <kaz@kylheku.com> - 2014-04-23 18:02 +0000
      Re: Updating C default type Keith Thompson <kst-u@mib.org> - 2014-04-23 11:33 -0700
  Re: Updating C default type Kaz Kylheku <kaz@kylheku.com> - 2014-04-22 19:08 +0000
    Re: Updating C default type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-22 22:08 +0100
      Re: Updating C default type "BartC" <bc@freeuk.com> - 2014-04-22 22:19 +0100
    Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-22 14:13 -0700
      Re: Updating C default type Stephen Sprunk <stephen@sprunk.org> - 2014-04-23 11:55 -0500
        Re: Updating C default type Keith Thompson <kst-u@mib.org> - 2014-04-23 10:55 -0700
          Re: Updating C default type Robert Wessel <robertwessel2@yahoo.com> - 2014-04-24 00:03 -0500
        Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-23 22:37 -0700
          Re: Updating C default type glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-24 12:05 +0000
      Re: Updating C default type gordonb.ez7sl@burditt.org (Gordon Burditt) - 2014-04-25 06:11 -0500
        Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-04-25 08:48 -0400
  Re: Updating C default type Stephen Sprunk <stephen@sprunk.org> - 2014-04-22 15:30 -0500
    Re: Updating C default type ralph <nt_consulting@yahoo.com> - 2014-04-22 23:18 -0500
  Re: Updating C default type Ken Brody <kenbrody@spamcop.net> - 2014-04-24 12:28 -0400
  Re: Updating C default type gordonb.oztxz@burditt.org (Gordon Burditt) - 2014-04-24 23:50 -0500
    Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-04-25 08:41 -0400
  Re: Updating C default type Hans Vlems <hvlems@freenet.de> - 2014-05-25 23:57 -0700
    Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-05-26 01:55 -0700
    Re: Updating C default type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-26 13:01 +0100
      Re: Updating C default type Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-05-26 13:12 -0700
        Re: Updating C default type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-26 22:31 +0100
          Re: Updating C default type Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-05-26 23:55 +0100
          Re: Updating C default type Keith Thompson <kst-u@mib.org> - 2014-05-26 17:11 -0700
    Re: Updating C default type James Kuyper <jameskuyper@verizon.net> - 2014-05-27 07:54 -0400

csiph-web