More int and float attributes

Paddy paddy3118 at netscape.net
Sun Aug 6 02:48:33 EDT 2006


Paddy wrote:
> bearophileHUGS at lycos.com wrote:
> > Paddy:
> > > Or do you mean the ability to choose between hardware supported float
> > > s? e.g. float and double precision?
> >
> > No, I mean just having the ability to ask the float (his attribute)
> > what are the max and min values it can represent, etc.
> >
> > stop = float.max
> > ...
> >
> > I don't know any simple way to know that values now. And importing sys
> > to know the max int looks stupid.
> >
> > maxi = int.max
> > mini = int.min
> > ...
> >
> > Such attributes can be given to the Decimal values too, if you want.
> >
> > Bye,
> > bearophile
> Hi  bearophille,
> decimals have their context; maybe floats could have your read-only
> 'context' values made available somehow. I don't know if their is an
> issue with making this (static) data available from all float
> instances, so maybe it should go in sys.
>
> Maybe people, (me included), don't pay enough attention to the
> trade-offs inherent in floating point arithmatic. I was taught about
> difference equations, and rounding errors. I regularly compute answers
> in programs without regard to floating point precision because the
> defaults chosen work for most of my cases, but if I needed to be more
> precise then I too would need some of the info you suggest.
>
> Question: do the scientific packages supported by Python supply this
> data in a regular manner?
>
> - Paddy.
>
> P.S. My appologies to any professional 'counters of currencies' out
> their who may have been offended by my earlier use of the term 'bean
> counters' - You probably earn much more than me - don't call in my
> loans - I have babes in arms to feed....  :-)

P.P.S. Just looking at the values you propose, if some of them can be
computed reliably from others (in the given float precision), then they
should NOT be included, but the module documentation should state how
they can be derived.




More information about the Python-list mailing list