How to get the minimum number that can be represented?

Peng Yu pengyu.ut at gmail.com
Sun Sep 20 08:15:11 EDT 2009


On Sun, Sep 20, 2009 at 12:46 AM, Daniel Fetchinson
<fetchinson at googlemail.com> wrote:
>> Suppose I want to define a function that return the minimum number
>> that can be represented.
>>
>> def f(x):
>>   #body
>>
>> That it, if I call f(10), f will return the minimum integer that can
>> be represented in the machine; if I cal f(10.5), f will return the
>> minimum float that can be represented in the machine.
>>
>> Could somebody let me know what should be in the function body?
>
> I'm not sure this is what you are looking for but have a look at
>
> import sys
> print sys.maxint

The problem is how to know what type of the argument and call the
corresponding function.

In C++, it is relatively easy (<limits> header). Is there an
equivalent in python?

Regards,
Peng



More information about the Python-list mailing list