OH NO NO NO NO

OH NO NO NO NO

Attached: 1546708590062.jpg (1021x437, 57K)

Other urls found in this thread:

en.wikipedia.org/w/index.php?title=IEEE_754#Rounding_rules
johngustafson.net/pdfs/BeatingFloatingPoint.pdf
github.com/python/cpython/blob/v3.7.2/Python/pymath.c#L71-L80
h-schmidt.net/FloatConverter/IEEE754.html
docs.python.org/3/tutorial/floatingpoint.html
dec64.com/
twitter.com/SFWRedditGifs

>OP is such a fag he doesn't know about float -> integer which is what round() does

It’s called banker’s rounding, you mongol

>1.5 -> 2
>float to integer
inbred

by default? lmao

what the fuck

Attached: decimal.png (666x413, 14K)

I've never really used Python 3.x before
Seriously what's going on?

Attached: image.jpg (608x307, 49K)

Ruby doesn't have this problem :^)

Attached: Screenshot_2019-01-05_20-56-35.png (307x266, 64K)

What's going on is that 3.x is a broken piece of garbage and nobody with half a brain uses it, which is why most niche (= useful) software is still 2.7 only.

The issue is likely float representation. It's inaccurate by design. When you type 4.5 literal the actual number stored might be something like 4.49999999999996 or something. There is Decimal class for accurate decimal arithmetic, but now I wonder how are you supposed to round it.

Bit rot
Both amd and intel are susceptible to loss of precision because to it. Power9 literally doesn't have this problem.

That wouldn't explain how no other language (even older python) has that problem.

this, /thread, sage

t. literal inbred

Python3 rounds to the nearest even integer.
en.wikipedia.org/w/index.php?title=IEEE_754#Rounding_rules

Nah, it even does this on my phone and I'm pretty sure it's not amd or intel

Attached: Capture+_2019-01-05-16-01-42.png (900x423, 67K)

>ITT: retards discover IEEE754

C# doesn't have this problem(since you can manually specify the rounding mode for these values).

Does power9 not follow IEEE standards or what?
Literally every other language have this problem. The older python uses insane amount of workarounds and it's not even a bad thing to get rid of them.
Though I googled how to properly round but it still doesn't work. The shit's weird.

Attached: thefuck.png (666x413, 16K)

>t. brainlets

The only correct post in this entire thread regarding the OP

What is IEEE round?
god, this place is becoming more retarded by the day.

>jewish rounding

based

Attached: Screen Shot 2019-01-05 at 1.08.28 PM.png (426x138, 42K)

Try not being inbred before your next post. Or off yourself. Eitherway is fine by me.

I understand sacrifices had to be made for the performance but is there any fucking way to avoid all of that floating point garbage other than rolling out a fucking symbolic algebra system. Like some compiler flag or a library.

>niche (= useful)
That's the opposite of true, otherwise it would be popular. It is niche because it is garbage.

Use floor or ceil you idiot, if you don't want it to use the default rounding algorithm you need to tell it what to do.

It's not even brainletism anymore. The correct answer is in the second post. I'm half convinced this thread is the work of a single troll, trying to run some sort of psychological warfare against us.

oh nono its true

It's rounding to the nearest even integer at .5, there's nothing much wrong with since rounding up is just convention.

>0 --> 0
>0.1 --> 0
>0.2 --> 0
>0.3 --> 0
>0.4 --> 0
>0.5 --> 1
>0.6 --> 1
>0.7 --> 1
>0.8 --> 1
>0.9 --> 1
>1 --> 1
>6 numbers are rounded up, but only 5 numbers are rounded down
Does that seem intelligent to you? No. That's the problem that the rounding system presented in the OP is meant to fix.

you're retarded

>all outputs are even
if only there were some sort of pattern to this

niche != not popular. Get a brain retard.

jjjjeeeeewwwwwsssss

oy vey python is shit and it's beautiful

Explain me this one.

*sip* And that's why I use COBOL folks

Attached: 1530330667534.jpg (675x601, 168K)

tfw I have a COBOL/JCL/SQL bootcamp upcoming in 9 days, gotta grind that Murach book.
i need this job.

use 2.7 like a normal person user

Attached: Screenshot from 2019-01-05 18-22-41.png (1391x714, 110K)

>(((banker)))

kek

ruby's (lack of) syntax drives me insane.

It's called incorrect and its a symptom of shit programmers.

> 1 -> 1 counts as rounding
You're an actual imbecile.

You don't have my permission to speak to me like that.

Lack of syntax? `1.5` is a Numeric literal but everything is an object in ruby, including primitives, so they have methods that can be invoked. There isn't a need for parentheses on function calls if there are no parameters and the language never deals with callbacks.

t. user talking out of his ass

Attached: rounding_power9.png (1046x294, 43K)

Only correct answers here

I'm gay btw

faggot

round converts decimal to a float

Python's lack of syntax drives me insane.

>The issue is likely float representation.
No.
It's pretty much intuitively clear that 4.5 has an exact representation, but you can check yourself that this is true.

Only if you use BCD to store the number.

>Only if you use BCD to store the number.
No.

It's true for the IEEE Standard for floating point numbers (and many other formats), which is something your language should *probably* implement.

Oh no, it's retarded.

>your language should *probably* implement.
It's not my language...
>It's true for the IEEE Standard for floating point numbers
Which standard are you referring to?

>It's not my language...
Yes, I know and I didn't address you.

>Which standard are you referring to?
IEEE 754
That thing that you can find about anywhere, especially in hardware.

0.5 = 1/2 ==binary==> 0.1 ==> 1e-1

You're retarded.

> I didn't address you.
You referenced my post.
>IEEE 754
>That thing that you can find about anywhere, especially in hardware.
I'm aware; I thought it was strange you didn't explicitly say IEE 754 earlier. Most languages will default to base two formats of the standard. If you need precise decimal representation, you need to specify that.

Also, these decimal formats have only existed for ten years now.

Attached: base.png (917x287, 26K)

And what does any of that have to do with my point of 4.5 being expressible in that standard?

python has syntax, it's just shit
ruby straight up doesn't
nothing is enforced
you can do whatever
you don't need a return, but you can have one
you don't need to specify function parameters but you can
etc.

ruby code is completely unreadable

and the rounding issue is with 4.5, what's your point?

4.5 = 9/2 ==binary==>????

You have to use BCD to store it precisely or store the quotient and dividend in their own variables.

>muh objecs
imagine using a POOlang

Attached: 385.jpg (317x267, 22K)

>IEEE 754
>That thing that you can find about anywhere, especially in hardware.
I'm aware; I thought it was strange you didn't explicitly say IEE 754 earlier. Most languages will default to base two formats of the standard. If you need precise decimal representation, you need to specify that.

Also, these decimal formats have only existed for ten years now.

Is Jow Forums really so technologically inept you don't get banker's rounding?

>he thinks rounding should be biased

Attached: annoyingorangesuit.png (245x511, 101K)

FUCKING AMERICANS LEAVE MY EUROPEAN MATHS ALONE REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

johngustafson.net/pdfs/BeatingFloatingPoint.pdf

Floating point was a mistake

>Rounding is done towards the closest even value
It's right there in the pydocs. RTFM idiot

You dumb fuck, both 3.5 and 4.5 are PRECISELY represented in binary floating point yet one is rounded upwards and the other is rounded downwards. It's not about the binary or decimal representation, the actual reason for that has already been said in this thread.

what's the ideal rounding method? justify your answer

depends on the context

≥ .5 is rounded up, the rest is rounded down.

I think rounding shouldn't be based on the utter stupidity.

Hello Vlad

github.com/python/cpython/blob/v3.7.2/Python/pymath.c#L71-L80
What exactly makes floor(fabs(x)) - fabs(x) >= 0.5 untrue here, given that 4.5 and 6.5 can be represented as exact floating point numbers?

This betta be bait

Trick question

4 - 4.5 = -0.5

Retarded niggers, this works even if you don't count integer numbers. No matter what direction you chose to round .5 to there's always going to be a preferred direction of rounding, ON AVERAGE. If round odd numbers up and even numbers down you compensate that, but again - only on average. Just do that for the range of (0;2) and see for yourself, banker's rounding will round exactly 50% of numbers. This should be the preferred method for stuff like statistics. But for implementing algorithms a more consistent approach should be chosen even if it's less accurate.

Hence why Python has implemented a non-stupid rounding function

Wrong. Bankers use ceil() for the money you owe them and floor() for the money they give you

No it's not.
If you can accurately represent rational number in base 2, you probably can do it in float.
4.5 is 100.12 = 1.0012 * 2^2 so 2 as exponent and 1.0012 as mantisa.

h-schmidt.net/FloatConverter/IEEE754.html

>100.12 = 1.0012
Jow Forums doesn't like subscript. That 2 was supposed to be subscript.

SPBP.
That said it's kind of bizare that they decided to do that. Not only people coming from 2.7 are going to have 'fun' time finding out their round function was `broken`, it's also not at all what I would expect from a std function.

That can't be real

Pardon, it's fabs(x) - floor(fabs(x)).
As far as I can see, the intermediate reasons for a little test C program are exact values of 4.5 and 0.5.

docs.python.org/3/tutorial/floatingpoint.html

Read the thread, nigger, all these numbers have a perfect floating point representation.

IEEE754

It's also a problem with very large numbers. Try it in your browser, open the console and type a large number without decimals, about 12 digits, you'll see the least significant digits change.

Python also rounds integers toward negative infinity instead of toward zero (which is how most C-like languages do it), so I'd say that doing banker's rounding by default isn't too far out compared to most other "pythonisms".

Only brainlets still use 2.x in 2019.

Which is why alternatives to IEEE754 exist:
dec64.com/

It's the same case as the integer division in py2. They'll probably fix it in py4 and with that force people to stay in py3 for 10 years after it's release.

why should they fix it? python's integer division is much more convenient to work with (especially with modulo with negative numbers). are Ctards really so autistic they start hissing and reeing whenever a language does something in a way they aren't used to?

>are Ctards really so autistic they start hissing and reeing whenever a language does something in a way they aren't used to?
Yes.