comp.lang.ada
 help / color / mirror / Atom feed
* Underscore ("_") in numeric literals
@ 1993-07-22 11:24 Dag Bruck
  0 siblings, 0 replies; 9+ messages in thread
From: Dag Bruck @ 1993-07-22 11:24 UTC (permalink / raw)


I would like to know to what extent people use undescore ("_")
characters in numeric literals, e.g., "100_000".  Please send me your
opinions, etc.

I would be particularly grateful if people could point me to Ada
source archives so I can make some simple statistical analysis of real
code, or if you would like to "grep" your own code and let me know
what you got.

The reason is that the C++ standardization committees have received a
proposal to allow "_" in numeric literals.  We are interested in some
sort of indication if people find this feature useful, and if it is
commonly used in languages that have it.  If nobody uses "_" there is
no reason to add it to C++, and if it provides a significant
improvement in readability, C++ could use all the help it can get :-)


			Thanks for your help,

			Dag Bruck

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-23 18:32 Mikey
  0 siblings, 0 replies; 9+ messages in thread
From: Mikey @ 1993-07-23 18:32 UTC (permalink / raw)


In article <22lte3$nqm@nic.lth.se> dag@control.lth.se (Dag Bruck) writes:
>
>I would like to know to what extent people use undescore ("_")
>characters in numeric literals, e.g., "100_000".  Please send me your
>opinions, etc.
>
>I would be particularly grateful if people could point me to Ada
>source archives so I can make some simple statistical analysis of real
>code, or if you would like to "grep" your own code and let me know
>what you got.
>
>The reason is that the C++ standardization committees have received a
>proposal to allow "_" in numeric literals.  We are interested in some
>sort of indication if people find this feature useful, and if it is
>commonly used in languages that have it.  If nobody uses "_" there is
>no reason to add it to C++, and if it provides a significant
>improvement in readability, C++ could use all the help it can get :-)
>
>
>			Thanks for your help,
>
>			Dag Bruck
>

As an amateur astronomer, I write many programs that involve numerical
analysis, orbit determination, orbit plots, etc., etc. I find that I use alot
of numerical constants in double-precision that I believe would be much easier
to update (when necessary - most astronomical constants don't change much :) )
and/or examine if I had the use of the "_". My Ada usage is limited to at work,
where I am the company's Ada instructor. I personally like the "_" and would
like to see it in C++. As for amount of usage; I would say about 10-20% of the
time in product code, but almost 100% in my sample code and exercises for my
Ada course material.

Mike M.
         __________________________________________________________________
        / Michael J. Mangieri                 Internet: mmangieri@vitro.com
__     /  Vitro Corporation                      Voice:      (301) 231-3016
  \   /   MX-SP 4-2311                             FAX:      (301) 231-1233
   \ /    14000 Georgia Ave.              
    *     Silver Spring, MD 20906-2972    

         "Everything should be made as simple as possible, but not simpler."
                                                       - A. Einstein

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-27 15:33 Charles H. Sampson
  0 siblings, 0 replies; 9+ messages in thread
From: Charles H. Sampson @ 1993-07-27 15:33 UTC (permalink / raw)


In article <22lte3$nqm@nic.lth.se> dag@control.lth.se (Dag Bruck) writes:
>
>I would like to know to what extent people use undescore ("_")
>characters in numeric literals, e.g., "100_000".  Please send me your
>opinions, etc.

     When I first saw the "underscore in numeric literals" feature I said,
"Interesting frill, but who cares?"  After all, my first non-assembly pro-
gramming was in FORTRANSIT and I have lots of experience in reading 10-digit
decimal literals.

     My style has since evolved to the point that I use the underscore in
any decimal literal longer than five digits.  That's on either side of the
decimal point.  When working with bit strings (base 2) I used it every
fourth bit to highlight the nybble boundaries.  I'd hate to do without it.

     Most of the people in my shop (who are admittely heavily influenced by
me) do the same.

				Charlie

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-27 20:17 Robert Dewar
  0 siblings, 0 replies; 9+ messages in thread
From: Robert Dewar @ 1993-07-27 20:17 UTC (permalink / raw)


Charlie's note pretty much reflects what I would think of as standard
Ada style, and a reasonable recipe for making use of a very useful
lexical convention.

What would be interesting is to understand why the question was asked in
the first place?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-28  5:41 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!agate!libra
  0 siblings, 0 replies; 9+ messages in thread
From: cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!agate!libra @ 1993-07-28  5:41 UTC (permalink / raw)


In article <22lte3$nqm@nic.lth.se> dag@control.lth.se (Dag Bruck) writes:
>
>I would like to know to what extent people use undescore ("_")
>characters in numeric literals, e.g., "100_000".  Please send me your
>opinions, etc.
>
>The reason is that the C++ standardization committees have received a
>proposal to allow "_" in numeric literals.  We are interested in some
>sort of indication if people find this feature useful, and if it is
>commonly used in languages that have it.  If nobody uses "_" there is
>no reason to add it to C++, and if it provides a significant
>improvement in readability, C++ could use all the help it can get :-)
>
>
>			Thanks for your help,
>
>			Dag Bruck

We use _ in all of our constants of 5 digits or greater, and in many that
are four digits long.  Very useful.  The Ada POSIX standard (IEEE Std
1003.5) uses it in the version identifier that is really a date.  It
has the form of dd_dddd (yes, four digits to the right of the underscore).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-28  5:43 Dag Bruck
  0 siblings, 0 replies; 9+ messages in thread
From: Dag Bruck @ 1993-07-28  5:43 UTC (permalink / raw)


In <comp.lang.ada> dewar@cs.nyu.edu (Robert Dewar) writes:
>
>What would be interesting is to understand why the question was asked in
>the first place?

There is a proposal to extend the syntax of C++ to include undescore
in numeric literals.   I wanted experience reports from a language
that has the feature.

I have received about 20 replies, all in favour.  Is there nobody in
the Ada community that thinks that it is a useless feature?  It seems
to rarely used for the simple reason that people rarely type big
numbers.

				-- Dag

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-07-28 14:22 Mike Berman
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Berman @ 1993-07-28 14:22 UTC (permalink / raw)


dag@control.lth.se (Dag Bruck) writes:

| I have received about 20 replies, all in favour.  Is there nobody in
| the Ada community that thinks that it is a useless feature?  It seems
| to rarely used for the simple reason that people rarely type big
| numbers.

The use of embedded underscores in numeric literals is probably
statistically small, but the aid to understanding is invaluable.

The best application that I've seen is in engineering applications,
where large constant values (e.g. Pi) are defined via named numbers so that
they support any degree of desired accuracy. Mostly, these values are found
in standard engineering tables, where the digits are grouped (usually in
fours, I think). Duplicating this same grouping by using the underscores
makes it quite easy to verify the code against the reference.


-- 
Mike Berman
University of Maryland, Baltimore County     Fastrak Training, Inc.
berman@umbc.edu                              (301)924-0050
       The views represented in the above post are my own.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-08-04 14:43 agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate.watson.ibm.com!yktnews.watson.ibm.com!ncohen
  0 siblings, 0 replies; 9+ messages in thread
From: agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate.watson.ibm.com!yktnews.watson.ibm.com!ncohen @ 1993-08-04 14:43 UTC (permalink / raw)


In article <23622cINN1er@umbc4.umbc.edu>, berman@umbc.edu (Mike Berman) writes:
 
|> dag@control.lth.se (Dag Bruck) writes: 
|>
|> | I have received about 20 replies, all in favour.  Is there nobody in
|> | the Ada community that thinks that it is a useless feature?  It seems
|> | to rarely used for the simple reason that people rarely type big
|> | numbers.
|>
|> The use of embedded underscores in numeric literals is probably
|> statistically small, but the aid to understanding is invaluable.
   ...

Underscores are especially helpful in based constants, like
16#7fff_ffff# or 2#0010_1100_0001_0000# (especially for specifiying the
value to be placed in a control register in which each bit has a special
purpose).

--
Norman H. Cohen    ncohen@watson.ibm.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Underscore ("_") in numeric literals
@ 1993-08-04 16:04 cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!saimiri.primate.wisc.ed
  0 siblings, 0 replies; 9+ messages in thread
From: cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!saimiri.primate.wisc.ed @ 1993-08-04 16:04 UTC (permalink / raw)


Use of the underscore is called for in the Ada Style Guide.

Brad

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~1993-08-04 16:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-07-27 20:17 Underscore ("_") in numeric literals Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1993-08-04 16:04 cis.ohio-state.edu!math.ohio-state.edu!sdd.hp.com!saimiri.primate.wisc.ed
1993-08-04 14:43 agate!howland.reston.ans.net!europa.eng.gtefsd.com!news.ans.net!newsgate.watson.ibm.com!yktnews.watson.ibm.com!ncohen
1993-07-28 14:22 Mike Berman
1993-07-28  5:43 Dag Bruck
1993-07-28  5:41 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!agate!libra
1993-07-27 15:33 Charles H. Sampson
1993-07-23 18:32 Mikey
1993-07-22 11:24 Dag Bruck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox