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


Groups > comp.lang.c > #43325

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-22 18:20 +0000
Organization Aioe.org NNTP Server
Message-ID <lj6bsg$nji$1@speranza.aioe.org> (permalink)
References <lj66ho$8fg$1@speranza.aioe.org>

Show all headers | View raw


Raj Pashwar <raj121190@hotmail.nospam.com> wrote:
> We know, that C was created when computers had poor CPU power, this led 
> to many design decisions for C.
 
> Many of these now, are out of date, because even small microprocessors, 
> have comparatively very powerful CPUs comparing to the 1970s.
 
> One good example, is the use of "int" as the default type. Today working 
> with floating point operands is NOT expensive for modern CPUs. A "double" 
> has much bigger range and precision than int. So a very easy improvement 
> to C, will be to make return types for most standard functions, into 
> "double".

There are a large number of algorithms that work with integers, and
not floating point values. Processors supply both data types to
allow for both kinds of algorithms. 

There are some languages, such as BASIC (in its original, and many
implementations) that only supply a floating point data type.
That is usually to make the langauge, and learning to use it,
simpler. It complicates many algorithms.

At the time when C was new, most numerical (floating point)
algorithms were written in Fortran, and C was mostly used for
problems that didn't need, or rarely needed, floating point.
 
> I.E. main() can return double, malloc() can take a double argument, ETC.
 
> Note, that a double can hold any int value, so any old code will be 
> portable easily, therefore NO reason not to implement this improvement 
> ASAP.

On many systems, the largest integer type holds values that can't
be represented in the largest floating point type.

Also, note that floating point and integer aren't the only possible
data types. There are systems that allow for non-integer fixed
point values that have a fixed number of (decimal or binary or ...)
digits after the radix point. Note that in most countries money
is commonly described in a system with two digits after the decimal
point. PL/I even allows for a negative number of digits after
the radix (two or ten) point. 

Another system sometimes used is rational (fractions) values.
(The only language in relatively common use that I know of with
a rational type is TIFF.) Each value is represented as a ratio
(fraction) of two 32 bit integers.

Sometimes I write programs in AWK that could also be written
in C.  AWK has some similarity to C, but no integer data type.

-- 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