From: MRAB on 16 Jul 2010 09:49 Lawrence D'Oliveiro wrote: > In message <mailman.749.1279159335.1673.python-list(a)python.org>, MRAB wrote: > >> Normally it's only string literals that could be so long that you might >> want to split them over several lines. It is somewhat unusual to have a >> _numeric_ literal that's very very long! > > Seems a peculiar assumption to make in a language that allows integers of > arbitrary length, does it not? What's the recommended maximum line length in Python? 80 characters? If you take into account indentation, etc, that's still a long integer. And it's still only the _recommended_ maximum.
From: Steven D'Aprano on 16 Jul 2010 10:17 On Fri, 16 Jul 2010 14:49:21 +0100, MRAB wrote: > Lawrence D'Oliveiro wrote: >> In message <mailman.749.1279159335.1673.python-list(a)python.org>, MRAB >> wrote: >> >>> Normally it's only string literals that could be so long that you >>> might want to split them over several lines. It is somewhat unusual to >>> have a _numeric_ literal that's very very long! >> >> Seems a peculiar assumption to make in a language that allows integers >> of arbitrary length, does it not? > > What's the recommended maximum line length in Python? 80 characters? If > you take into account indentation, etc, that's still a long integer. And > it's still only the _recommended_ maximum. Not only that, but it only takes 73 digits to write out the total number of particles in the entire universe: 1000000000000000000000000000000000000000000000000000000000000000000000000 or 1e72. (Of course that's the lower-bound, estimates range from 1e72 all the way up to 1e87.) So for anything related to counting or labelling actual, physical objects, you will be dealing with smaller numbers than that. E.g. the number of grains of sand on the earth has been estimated (very roughly) as a mere 1000000000000000000000000, or 25 digits. It always makes me laugh when I receive an invoice from some company, and the account number or invoice number is (e.g.) 1000000023456789. Who do they think they're fooling? -- Steven
From: MRAB on 16 Jul 2010 10:41 Steven D'Aprano wrote: > On Fri, 16 Jul 2010 14:49:21 +0100, MRAB wrote: > >> Lawrence D'Oliveiro wrote: >>> In message <mailman.749.1279159335.1673.python-list(a)python.org>, MRAB >>> wrote: >>> >>>> Normally it's only string literals that could be so long that you >>>> might want to split them over several lines. It is somewhat unusual to >>>> have a _numeric_ literal that's very very long! >>> Seems a peculiar assumption to make in a language that allows integers >>> of arbitrary length, does it not? >> What's the recommended maximum line length in Python? 80 characters? If >> you take into account indentation, etc, that's still a long integer. And >> it's still only the _recommended_ maximum. > > Not only that, but it only takes 73 digits to write out the total number > of particles in the entire universe: > > 1000000000000000000000000000000000000000000000000000000000000000000000000 > > or 1e72. (Of course that's the lower-bound, estimates range from 1e72 all > the way up to 1e87.) So for anything related to counting or labelling > actual, physical objects, you will be dealing with smaller numbers than > that. E.g. the number of grains of sand on the earth has been estimated > (very roughly) as a mere 1000000000000000000000000, or 25 digits. > > It always makes me laugh when I receive an invoice from some company, and > the account number or invoice number is (e.g.) 1000000023456789. Who do > they think they're fooling? > It's possible that they're splitting it into fields.
From: bart.c on 16 Jul 2010 13:30 "Steven D'Aprano" <steve(a)REMOVE-THIS-cybersource.com.au> wrote in message news:4c4069de$0$11101$c3e8da3(a)news.astraweb.com... > On Fri, 16 Jul 2010 14:49:21 +0100, MRAB wrote: > Not only that, but it only takes 73 digits to write out the total number > of particles in the entire universe: > > 1000000000000000000000000000000000000000000000000000000000000000000000000 > > or 1e72. (Of course that's the lower-bound, estimates range from 1e72 all > the way up to 1e87.) > So for anything related to counting or labelling > actual, physical objects, you will be dealing with smaller numbers than > that. E.g. the number of grains of sand on the earth has been estimated > (very roughly) as a mere 1000000000000000000000000, or 25 digits. Big integers tend to be used for playing around with mathematical ideas, and they have to be exact. So if you wanted to hardcode 1000! for some reason, you'd need some 2568 digits which is a little awkward on one line. > It always makes me laugh when I receive an invoice from some company, and > the account number or invoice number is (e.g.) 1000000023456789. Who do > they think they're fooling? I used to do that. Giving someone an invoice number, or product serial number, 000001 doesn't exactly give the impression of a thriving business. -- Bartc
From: Robert Kern on 16 Jul 2010 14:28 On 7/16/10 12:30 PM, bart.c wrote: > > "Steven D'Aprano" <steve(a)REMOVE-THIS-cybersource.com.au> wrote in message > news:4c4069de$0$11101$c3e8da3(a)news.astraweb.com... >> On Fri, 16 Jul 2010 14:49:21 +0100, MRAB wrote: > >> Not only that, but it only takes 73 digits to write out the total number >> of particles in the entire universe: >> >> 1000000000000000000000000000000000000000000000000000000000000000000000000 >> >> or 1e72. (Of course that's the lower-bound, estimates range from 1e72 all >> the way up to 1e87.) >> So for anything related to counting or labelling >> actual, physical objects, you will be dealing with smaller numbers than >> that. E.g. the number of grains of sand on the earth has been estimated >> (very roughly) as a mere 1000000000000000000000000, or 25 digits. > > Big integers tend to be used for playing around with mathematical ideas, and > they have to be exact. So if you wanted to hardcode 1000! for some reason, you'd > need some 2568 digits which is a little awkward on one line. This happens too rarely to justify adding line-spanning integer literals to the language's syntax. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Issue with logging.config Next: whitespace in a word doc |