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


Groups > comp.lang.python > #89854

Re: Converting 5.223701009526849e-05 to 5e-05

References <87vbgakrlr.fsf@Equus.decebal.nl> <mailman.52.1430642455.12865.python-list@python.org> <87mw1mkoc5.fsf@Equus.decebal.nl> <mailman.59.1430646707.12865.python-list@python.org> <87egmykmhe.fsf@Equus.decebal.nl>
Date 2015-05-03 20:57 +1000
Subject Re: Converting 5.223701009526849e-05 to 5e-05
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.61.1430650648.12865.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, May 3, 2015 at 8:02 PM, Cecil Westerhof <Cecil@decebal.nl> wrote:
>>> If the absolute value is bigger as 0 and smaller as 1, it should be
>>> a float. ;-)
>>
>> Or maybe a fractions.Fraction, or a decimal.Decimal, or a complex,
>> or maybe a RXSTRING or a Gmp.mpf! There's more than one way to store
>> a number...
>
> Oops. :'-(
> I still have to learn a lot.

We all do :) Not all of those are Python types, incidentally. The
first three are, although 'complex' is a bit of a cheat (a complex
number is stored as two floats, so a complex with an imag of 0 is
virtually identical to a straight float); RXSTRING is the one and only
data type in REXX, and is (as the name suggests) stored as a string;
and Gmp.mpf is Pike's data type for a floating-point value stored
using the GNU Multiprecision library (gmp), and is thus capable of
arbitrary precision storage just like Python's own integer type. And
of course, the old fogeys among us know a bunch more ways to store
floating point values - not to mention all the ways of storing *fixed*
point values (the simplest being to just store an integer with the
number of hundredths of whatever it is you have - eg storing a dollar
amount as an integral number of cents). You'd be amazed how many
different ways there are of doing the same thing!

ChrisA

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


Thread

Converting 5.223701009526849e-05 to 5e-05 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 10:11 +0200
  Re: Converting 5.223701009526849e-05 to 5e-05 Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 18:40 +1000
    Re: Converting 5.223701009526849e-05 to 5e-05 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 11:22 +0200
      Re: Converting 5.223701009526849e-05 to 5e-05 Chris Angelico <rosuav@gmail.com> - 2015-05-03 19:51 +1000
        Re: Converting 5.223701009526849e-05 to 5e-05 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-03 12:02 +0200
          Re: Converting 5.223701009526849e-05 to 5e-05 Chris Angelico <rosuav@gmail.com> - 2015-05-03 20:57 +1000
      Re: Converting 5.223701009526849e-05 to 5e-05 Dave Angel <davea@davea.name> - 2015-05-03 07:34 -0400
  Re: Converting 5.223701009526849e-05 to 5e-05 Ben Finney <ben+python@benfinney.id.au> - 2015-05-03 18:48 +1000
    Re: Converting 5.223701009526849e-05 to 5e-05 Alexander Blinne <news@blinne.net> - 2015-05-07 10:00 +0200

csiph-web