Re: Rounding
P_at_draigBrady.com
Date: 11/04/03
- Next message: Edvard Majakari: "Using debug print routine inside assert"
- Previous message: Ville Vainio: "Re: bash Vs python ??"
- In reply to: Zunbeltz Izaola: "Rounding"
- Next in thread: Zunbeltz Izaola: "Re: Rounding"
- Reply: Zunbeltz Izaola: "Re: Rounding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 04 Nov 2003 12:13:25 +0000
Zunbeltz Izaola wrote:
> Hi to all!
>
> I want to know if it is possible to round a floating number to
> multiples of another number. An example:
> I've spam = 0.36 and foo = 0.38 and i want something like this:
>
>
>>>>round(spam,0.25)
>
> 0.25
>
>>>>round(foo,0.25)
>
> 0.50
>
> I know that builtin round rounds to a decimal position, but is there a
> module (or it is easy to code) with a function like this?
def roundto(num,round_multiple):
return round(num/round_multiple)*round_multiple
Pádraig.
- Next message: Edvard Majakari: "Using debug print routine inside assert"
- Previous message: Ville Vainio: "Re: bash Vs python ??"
- In reply to: Zunbeltz Izaola: "Rounding"
- Next in thread: Zunbeltz Izaola: "Re: Rounding"
- Reply: Zunbeltz Izaola: "Re: Rounding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|