Seite 1 von 1

runden around round

Verfasst: Freitag 23. Oktober 2009, 10:49
von Sirius
Hallo, ich möchte einen array runden.
Nur kommt da etwas komisches raus

Wie es sein muss, gibt round(0.5)
1

komischerweise gibt around(arange(0,1,0.1))
[ 0. 0. 0. 0. 0. 0. 1. 1. 1. 1.]

also von 0.5 rundet er ab auf 0. Wo liegt das Problem? Wie kann ich es beheben?
Im Internet finde ich leider nur schlechte Angaben zum Befehl around, oder ähnlichen.

Verfasst: Freitag 23. Oktober 2009, 11:08
von jbs
Aus numpy:
Notes
-----
For values exactly halfway between rounded decimal values, Numpy
rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0,
-0.5 and 0.5 round to 0.0, etc. Results may also be surprising due
to the inexact representation of decimal fractions in the IEEE
floating point standard [1]_ and errors introduced when scaling
by powers of ten.

Verfasst: Freitag 23. Oktober 2009, 11:10
von Sirius
achsooo

is zwar eine komische Logik. Aber ich zähl dann halt immer 0.00001 dazu vor dem runden...

Danke