digitalmars.D - Integral literals with Exp?
- bearophile (7/7) Sep 13 2014 Is it a good idea to accept code like this, to shorten some
- Walter Bright (2/6) Sep 14 2014 1_000_000 solves that problem.
- John Colvin (2/10) Sep 15 2014 How does adding extra _s help with shortening constants?
- Walter Bright (2/12) Sep 15 2014 Readability is the goal, not minimizing the number of characters.
- eles (5/11) Sep 15 2014 Exactly:
- Nicolas Sicard (2/14) Sep 15 2014 What integral type would hold that value?
- eles (5/13) Sep 15 2014 Good question. This one, of course:
- Andrei Alexandrescu (2/12) Sep 15 2014 Nice :o). To the original idea, the short answer would be no. -- Andrei
- matovitch (6/13) Sep 15 2014 Well, I guess it wouldn't help the lexer. To be consistent :
- ketmar via Digitalmars-d (8/17) Sep 15 2014 both numbers aren't ints. the first is obviously "173.0", not "173".
Is it a good idea to accept code like this, to shorten some constants? void main() { int x = 1e6; } Bye, bearophile
Sep 13 2014
On 9/13/2014 12:23 AM, bearophile wrote:Is it a good idea to accept code like this, to shorten some constants? void main() { int x = 1e6; }1_000_000 solves that problem.
Sep 14 2014
On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:On 9/13/2014 12:23 AM, bearophile wrote:How does adding extra _s help with shortening constants?Is it a good idea to accept code like this, to shorten some constants? void main() { int x = 1e6; }1_000_000 solves that problem.
Sep 15 2014
On 9/15/2014 1:54 AM, John Colvin wrote:On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:Readability is the goal, not minimizing the number of characters.On 9/13/2014 12:23 AM, bearophile wrote:How does adding extra _s help with shortening constants?Is it a good idea to accept code like this, to shorten some constants? void main() { int x = 1e6; }1_000_000 solves that problem.
Sep 15 2014
On Monday, 15 September 2014 at 09:13:52 UTC, Walter Bright wrote:On 9/15/2014 1:54 AM, John Colvin wrote:On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:On 9/13/2014 12:23 AM, bearophile wrote:Readability is the goal, not minimizing the number of characters.Exactly: 6.02214129×10^23 http://en.wikipedia.org/wiki/Avogadro_constant Some constants are widely known in the eXX form.
Sep 15 2014
On Monday, 15 September 2014 at 09:19:12 UTC, eles wrote:On Monday, 15 September 2014 at 09:13:52 UTC, Walter Bright wrote:What integral type would hold that value?On 9/15/2014 1:54 AM, John Colvin wrote:On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:On 9/13/2014 12:23 AM, bearophile wrote:Readability is the goal, not minimizing the number of characters.Exactly: 6.02214129×10^23 http://en.wikipedia.org/wiki/Avogadro_constant Some constants are widely known in the eXX form.
Sep 15 2014
On Monday, 15 September 2014 at 11:31:26 UTC, Nicolas Sicard wrote:On Monday, 15 September 2014 at 09:19:12 UTC, eles wrote:On Monday, 15 September 2014 at 09:13:52 UTC, Walter Bright wrote:On 9/15/2014 1:54 AM, John Colvin wrote:On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:On 9/13/2014 12:23 AM, bearophile wrote:What integral type would hold that value?Good question. This one, of course: http://en.wikipedia.org/wiki/Mole_(unit) Just joking.
Sep 15 2014
On 9/15/14, 4:48 AM, eles wrote:On Monday, 15 September 2014 at 11:31:26 UTC, Nicolas Sicard wrote:Nice :o). To the original idea, the short answer would be no. -- AndreiOn Monday, 15 September 2014 at 09:19:12 UTC, eles wrote:On Monday, 15 September 2014 at 09:13:52 UTC, Walter Bright wrote:On 9/15/2014 1:54 AM, John Colvin wrote:On Monday, 15 September 2014 at 00:54:40 UTC, Walter Bright wrote:On 9/13/2014 12:23 AM, bearophile wrote:What integral type would hold that value?Good question. This one, of course: http://en.wikipedia.org/wiki/Mole_(unit) Just joking.
Sep 15 2014
On Saturday, 13 September 2014 at 07:23:39 UTC, bearophile wrote:Is it a good idea to accept code like this, to shorten some constants? void main() { int x = 1e6; } Bye, bearophileWell, I guess it wouldn't help the lexer. To be consistent : int x = 1.73e2; should be allowed but not int y = 1.73e1; Not a good idea IMHO.
Sep 15 2014
On Mon, 15 Sep 2014 09:05:09 +0000 matovitch via Digitalmars-d <digitalmars-d puremagic.com> wrote:Well, I guess it wouldn't help the lexer. To be consistent : =20 int x =3D 1.73e2; =20 should be allowed but not =20 int y =3D 1.73e1; =20 Not a good idea IMHO.both numbers aren't ints. the first is obviously "173.0", not "173". more convoluted sample: is "1000e-3" represents "1" or "1.0"? for all my scripting languages where having separated ints and floats makes any sense, i'm using this rules: 1. number with point in it is always float. 2. number with negative exponent is always float.
Sep 15 2014