Hirdetés

Új hozzászólás Aktív témák

  • sztanozs

    veterán

    válasz mylastage #2924 üzenetére

    Pascalban az int változó sose vett fel tört értéket. Szerintem az emlékeid ködösítik a múltat. Persze ettől függetlenül a Real így működött, de az már a régmúlt.

    Ráadásul ez nem egy python 'tulajdonság' igazából, az utóbbi időben (nem 25 évvel ezelőtt) már ez (banker's round) a sztenderd, azaz a felet mindig a közelebbi páros számhoz kell kerekíteni. Ez egy komolyabb (statisztikai) problémát old meg, mivel a 0.5 mindig felfelé kerekítése mérhető mértékben eltolja a kerekített számok eloszlását.

    What’s New In Python 3.0:
    The round() function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even result instead of away from zero. (For example, round(2.5) now returns 2 rather than 3.)
    For the built-in types supporting round(), values are rounded to the closest multiple of 10 to the power minus n; if two multiples are equally close, rounding is done toward the even choice.

    +
    Python 3's way (called "round half to even" or "banker's rounding") is considered the standard rounding method these days, though some language implementations aren't on the bus yet.
    The simple "always round 0.5 up" technique results in a slight bias toward the higher number. With large numbers of calculations, this can be significant. The Python 3.0 approach eliminates this issue.

Új hozzászólás Aktív témák