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


Groups > comp.lang.c > #124149

Re: High level programming in C

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: High level programming in C
Date 2017-12-11 17:49 +0000
Organization A noiseless patient Spider
Message-ID <87a7yp17f3.fsf@bsb.me.uk> (permalink)
References (6 earlier) <FilTpSjMnY9wuvVjUbmHkfJSOYBy@bongo-ra.co> <ov20b7$mne$1@dont-email.me> <32GuZQNXldTHOywj47SXFUBHgOo1Y@bongo-ra.co> <cMCdna4ZXpLHZ7DHnZ2dnUU7-QHNnZ2d@posted.internetamerica> <60cf0ee0-4752-45ee-802e-7e3de4bb979f@googlegroups.com>

Show all headers | View raw


David Kleinecke <dkleinecke@gmail.com> writes:

> On Sunday, December 10, 2017 at 7:24:21 PM UTC-8, Gordon Burditt wrote:
>> > Are there applications where one wants 128 bit (integer ?) mathematics
>> > but not above ?
>> 
>> Maybe.  Most of the math might fit in integers fine (e.g. currency
>> transaction amounts, which for the USA might be in integer quantities
>> of cents), but some of it needs additional percentages to do accurate
>> rounding (e.g.  sales tax calculations, where the sales tax might
>> be 7.625% = 7625 / 100000, or interest on loans ).
>> 
>> For this it helps to have a function (or inline code pattern for
>> the compiler) which multiplies two 64-bit numbers and divides by a
>> 64-bit number to give a 64-bit result with correct rounding.  (Note
>> using different numbers (likely powers of 10) in the denominator,
>> adjusting the numerator accordingly, may give different rounding,
>> and which you need to use is probably determined by law).  You need
>> 128 bits for the intermediate result.  This allows for the possibility
>> that you might have to compute sales taxes (or real estate taxes)
>> on large areas of real estate, say, Earth, or very expensive military
>> weapons systems.
>> 
>> This might not cover *all* of the math you need for handling currency,
>> but it might cover enough for some applications.
>
> One way to get involved with large integers is to try to
> build an API for rational numbers. So far as I know there
> is none readily available.

Maybe you mean something else, but I think are a quite a few.  GMP is
widely used but there are others.  And they are built into some
programming languages.

> But conceptually the job is
> rather easy. I know of no "practical" problems that require
> a solution in rationals and that probably explains why they
> get no attention from programmers.

Computer algebra systems need them.

For general numerical work, they suffer from the fact that they can grow
to use a lot of storage quite quickly (even when the rational value
remains small).

-- 
Ben.

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


Thread

High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-20 12:14 +0100
  Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-20 12:52 +0100
    Re: High level programming in C Robert Wessel <robertwessel2@yahoo.com> - 2017-11-20 06:07 -0600
      Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-20 13:38 +0100
        Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-20 14:23 +0100
          Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-20 16:56 +0100
          Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-20 17:14 +0000
            Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-20 17:21 +0000
  Re: High level programming in C "Mr. Man-wai Chang" <toylet.toylet@gmail.com> - 2017-11-20 22:45 +0800
  Re: High level programming in C Ian Collins <ian-news@hotmail.com> - 2017-11-21 07:30 +1300
    Re: High level programming in C gazelle@shell.xmission.com (Kenny McCormack) - 2017-11-20 18:32 +0000
      Re: High level programming in C jameskuyper@verizon.net - 2017-11-20 11:05 -0800
        Re: High level programming in C Öö Tiib <ootiib@hot.ee> - 2017-11-20 12:59 -0800
          Re: High level programming in C BGB <cr88192@hotmail.com> - 2017-11-22 10:47 -0600
  Re: High level programming in C fir <profesor.fir@gmail.com> - 2017-11-20 13:17 -0800
    Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 03:26 -0800
      Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 14:54 +0100
        Re: High level programming in C scott@slp53.sl.home (Scott Lurndal) - 2017-11-21 14:51 +0000
          Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-21 16:43 +0100
            Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 07:58 -0800
              Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 17:35 +0100
              Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-21 16:38 +0000
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 08:47 -0800
                Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 17:55 +0100
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 09:06 -0800
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 09:13 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-21 11:29 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-21 11:59 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-21 12:52 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-21 13:43 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-21 14:17 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-21 15:00 -0800
                Re: High level programming in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-11-21 15:17 -0700
                Re: High level programming in C supercat@casperkitty.com - 2017-11-21 15:09 -0800
                Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 00:55 +0100
                Re: High level programming in C "James R. Kuyper" <jameskuyper@verizon.net> - 2017-11-21 18:58 -0500
                Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-22 01:19 +0100
                Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-22 01:47 +0000
                Re: High level programming in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-11-21 21:48 -0700
                Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-22 07:36 +0000
                Re: High level programming in C "James R. Kuyper" <jameskuyper@verizon.net> - 2017-11-22 12:45 -0500
                Re: High level programming in C supercat@casperkitty.com - 2017-11-22 14:00 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-22 14:25 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-22 15:14 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-22 16:08 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-23 16:42 -0800
                Re: High level programming in C bartc <bc@freeuk.com> - 2017-11-24 01:37 +0000
                Re: High level programming in C supercat@casperkitty.com - 2017-11-24 14:33 -0800
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 16:20 -0800
                Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-22 10:39 +0100
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-23 02:59 -0800
                Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-23 12:24 +0100
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-23 04:49 -0800
                Re: High level programming in C scott@slp53.sl.home (Scott Lurndal) - 2017-11-22 15:42 +0000
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-22 08:57 -0800
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-11-21 09:19 -0800
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 09:28 -0800
                Re: High level programming in C supercat@casperkitty.com - 2017-11-21 09:22 -0800
            Re: High level programming in C scott@slp53.sl.home (Scott Lurndal) - 2017-11-21 16:29 +0000
              Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 17:43 +0100
          Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 17:40 +0100
            Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 08:52 -0800
              Re: High level programming in C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-11-21 09:28 -0800
                Re: High level programming in C Thiago Adams <thiago.adams@gmail.com> - 2017-11-21 09:34 -0800
        Re: High level programming in C Robert Wessel <robertwessel2@yahoo.com> - 2017-11-21 11:37 -0600
          Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 20:28 +0100
            Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-21 19:45 +0000
              Re: High level programming in C "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2017-11-21 11:51 -0800
              Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-11-21 20:55 +0100
                Re: High level programming in C Spiros Bousbouras <spibou@gmail.com> - 2017-11-21 20:07 +0000
                Re: High level programming in C Ian Collins <ian-news@hotmail.com> - 2017-11-22 09:13 +1300
                Re: High level programming in C scott@slp53.sl.home (Scott Lurndal) - 2017-11-22 15:38 +0000
                Re: High level programming in C Robert Wessel <robertwessel2@yahoo.com> - 2017-11-21 15:17 -0600
                Re: High level programming in C Ian Collins <ian-news@hotmail.com> - 2017-11-22 10:25 +1300
                Re: High level programming in C Robert Wessel <robertwessel2@yahoo.com> - 2017-11-21 15:41 -0600
                Re: High level programming in C gordonb.fqrzr@burditt.org (Gordon Burditt) - 2017-12-10 21:24 -0600
                Re: High level programming in C David Kleinecke <dkleinecke@gmail.com> - 2017-12-10 20:03 -0800
                Re: High level programming in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-12-11 17:49 +0000
                Re: High level programming in C David Kleinecke <dkleinecke@gmail.com> - 2017-12-11 10:32 -0800
                Re: High level programming in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-12-12 01:33 +0000
                Re: High level programming in C David Kleinecke <dkleinecke@gmail.com> - 2017-12-11 18:34 -0800
                Re: High level programming in C jacobnavia <jacob@jacob.remcomp.fr> - 2017-12-11 20:09 +0100
                Re: High level programming in C Keith Thompson <kst-u@mib.org> - 2017-12-11 11:23 -0800
                Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-22 11:01 +0100
              Re: High level programming in C antispam@math.uni.wroc.pl - 2017-11-21 20:11 +0000
              Re: High level programming in C David Brown <david.brown@hesbynett.no> - 2017-11-22 10:58 +0100

csiph-web