Python Oddities: did you know THIS about the round() function? #python #programming

preview_player
Показать описание
Like & subscribe for more python programming content!

#programming #coding #pythonbeginners #python3 #pythonforbeginners #pythonbasics
Рекомендации по теме
Комментарии
Автор

Only 0.5 is rounded to even and "reducing the error" is a vague statement as it changes the type of expected error. Depending on the numbers chosen it can devolve into either always up or always down, but it has an inherent bias towards even numbers.

And this is not a Python oddity nor Pythons decision:
Python is using IEEE-754 floats and it is that specification that defines how floats are rounded.

ABaumstumpf
Автор

I thought it was some quirk of float representation, like with 0.1 + 0.2, but turns out it was fully intentional! That sounds like it would've been a pain to implement, but it's very cool!

thatotherandrew_
Автор

this channel should have way more subscribers

thierryrioual
Автор

Cool didn't know that.
Love your videos

terageekg
Автор

I strangely learned this in machine shop. Shop teacher was big on probability as it relates to measurement. Like "What are the chances you can actually machine those tolerances?"

ross
Автор

this one i have seen in PascalABC, i think. called it banker's rounding

no-better-name
Автор

But is there a "normal" regular round function in python?

mart_of_chaos
Автор

What about rounding off? It depends on the digit we are rounding, so 7.5 -> 8, -> 7, 7.4 -> 7 etc.

mumujibirb
Автор

Is this because it rounds in the way that mathematicians do (toward the nearest even integer when the input is equally spaced between two integers)? If so, this is a natural and unbiased approach.

curtiswfranks
Автор

Round to nearest even has been around since the 8087 and probably longer, hasn't it?

cmilkau
Автор

yeah great, but how do we do rounding as we were taught in school?

calcubite
Автор

Where are more videos bruh upload upload upload more

tommyshelby
Автор

so what does a 8.6 get rounded down to 8? You said round down to the nearest even integer. I dont'get it

vinnieg
Автор

plz talk slowly with more visualization if possible

slimysnail
Автор

Is it rounding to nearest even number? If not, how does it work in multi-threading?

cipherxen
Автор

That's how it's always been, what did they teach you to do with halves?

javier