What's the "strangest" thing your program did and you were surprised by it?

What's the "strangest" thing your program did and you were surprised by it?

I'll start with one of the most famous example:
0.1 + 0.2 = 0.30000000000000004

Attached: 2.gif (150x107, 244K)

Other urls found in this thread:

0.30000000000000004.com/
docs.python.org/3/whatsnew/3.0.html#builtins
mikemcl.github.io/big.js/
en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest
en.wikipedia.org/wiki/Flow_(psychology)
twitter.com/SFWRedditVideos

Windows 10 updated without problems.

>Using JavaScript
Lol

Having no merge conflicts after not pulling for two days

The highest and lowest values within error of a best fit are both lower than the value of a best fit to a model

>he thinks it's a javascript thing
brainlet stemlord

You're a fucking retard.

round(1.5) == round(2.5)
This is true in Python.

That's banker's rounding innit

isn't that a bug?

>>> round(1.5)
2
>>> round(2.5)
2
>>> round(3.5)
4
>>> round(4.5)
4

Attached: 1557271886547.png (374x376, 221K)

In C/C++ :

>>> int i = 111+011+001;
>>> cout

why does it do that?

>c/c++
>cout
fucking retard

haha, never mind. i found it. :)

printf("%d\n", i); then you fucking mong

>cout printf("%d\n", i);
your sepples version doesn't have endl you fucking retard.

Imagine being such an uneducated room temperature IQ nigger on Jow Forums of all places.
0.30000000000000004.com/

That's the issue with floats. They're not very precise.

$x = 10;
$y = 5;

$z = $x > $y ? 1 : $x < $y ? -1 : 0;

Haha, guess the the value of $z.

>tfw worked in a company that used PHP and I included double ternary in their code base.
I wonder how many problems this eventually caused to them.

011 = 9 because a number beginning with 0 is an octal number in the C family of languages. This result is absolutely normal.

Apparently this is a common thing for those learning python to run into.
>>>list1 = [1]
>>>list1 *= 5
>>>list1[2] += 1
>>>print(list1)
[1, 1, 2, 1, 1]

Seems normal right? Thats because it is. However...
>>>list2 = [[]] #list containing 1 empty list
>>>list2 *= 5
>>>list2[2].append(1) #put a 1 in the list in list2[2], and not in any of the others
>>>print(list2)
[[1], [1], [1], [1], [1]]

This had me going nuts over why my hashtable had every single entry in every row. It happens to the empty lists and not the 1's because of how python handles objects vs literals. The proper way to do what i tried is [[] for i in range(5)].

It worked.
import Data.Bifunctor

xgcdL :: Integral a => [a] -> (a, [a])
xgcdL xs = aux xs 1
where aux [] _ = undefined -- pattern warning go away
aux [m] a = (m, [a])
aux (m:ms) a =
let (g, xs') = aux ms (y*a)
(g', (x, y)) = xgcd m g
in (g', (a*x):xs')

divides :: Integral a => a -> a -> Bool
x `divides` y = y `mod` x == 0

swap = uncurry . flip . curry $ id

xgcd :: (Integral a) => a -> a -> (a, (a, a))
xgcd a 0 = (a, (1, 0))
xgcd 0 b = (b, (0, 1))
xgcd a b | 2 `divides` a && 2 `divides` b = first (2*) $ xgcd (a`div`2) (b`div`2)
xgcd a b | 2`divides`b = second (\(x, y) -> if 2 `divides` y
then (x, y`div`2)
else (x - b`div`2, (y+a)`div`2))
$ xgcd a (b`div`2)
xgcd a b | 2`divides`a = second swap $ xgcd b a
xgcd a b | a (x - y, y)) $ xgcd a (b - a)
xgcd a b | a > b = second swap $ xgcd b a
xgcd _ _ = undefined -- pattern warning go away

main = putStrLn . show $ xgcdL [30, 45, 12]

Whats the problem with that? What does it output? Ive used double ternary operators in js before without problems

Looks pretty fucking precise to me. Unless you're going to Jupiter with out any onboard control systems, I think 4 billionth is pretty good.

It's a problem in PHP only.
PHP evaluates ternary in some retarded order, as result the return of that condition will never be 1.

Seems Jewish

wtf is that fucking stupid shit

Is my Python interpreter retarded?

Attached: 2019-06-10-212417_681x382_scrot.png (681x382, 764K)

Aside from surprises that libraries have thrown at me, for example, X11's various bugs and inadequacies, i can't think of much. Floating point precision errors do come to mind though. I have underestimated the degree which precision errors can accumulate.

Attached: psx.jpg (271x266, 10K)

Extended gcd for multiple arguments.

Nope, it started happening in python version 3.0

docs.python.org/3/whatsnew/3.0.html#builtins

see 4th paragraph

>0.1 + 0.2

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

Attached: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah.png (944x449, 36K)

I don't see any problem.

Attached: chrome_2019-06-10_21-05-02.png (503x79, 4K)

Why was it changed? It doesn't seem.to make sense.

>pycharm

Ternary in PHP is left-associative, ternary in literally every other language with a ternary operator is right-associative.

This expression: a ? b : c ? d : e
in PHP is this nonsense: (a ? b : c) ? d : e
instead of the sensible: a ? b (c ? d : e)

if i will type 0.10 + 0.20 will i get rounded value instead of this rounded up ?
i'm a brainlet on this

One of many, many, many idiotic things in that broken language. I have no idea why is someone using that crap.

C/C++

const int n = 3;
float vec[n];
for(int i = 0; i < n; ++i)
i[vec] = 0.0;

const char *vars[] = { "%d ","Fizz ","Buzz ","FizzBuzz " };
for (int i = 1; i < 101; ++i)
printf(vars[(i % 3 == 0) + (i % 5 == 0)*2], i);

For any newbs itt:
if you're developing an application that in which you can not tolerate rounding errors, use an arbitrary precision arithmetic library. For JS, the probably most well known is big.js:
mikemcl.github.io/big.js/

I come from a C# background and am now working as a PHP dev with others PHP devs who have only ever known PHP and JS.
Because they've never seen anything else, they think it's a good language.

W A L L Y

>Exact halfway cases are now rounded to the nearest even result instead of away from zero.
fucking what?

What's wrong with pycharm?
I don't know why the fuck you would use it for something as simple as that but it seems like a solid IDE

Is this an April fools joke they forgot to get rid of?

Brainlet think about boolean operations

You are literally retarded and an embarrassment to this entire board.

>best known is
Fixed.

>I think 4 billionth is pretty good.
that's not how this works

for the retards in this thread
en.wikipedia.org/wiki/IEEE_754#Roundings_to_nearest

what's your definition of "precise"?

All JetBrains software is overpriced bloat.
Go into any office in a big city like London and the guys that use intelliJ are the same hipster retards that are walking around with overprice Apple laptops and beard oil in their Cambridge bloody satchel.

you sound like a mad poorfag, even their free shit is great and their design philosophy is literally based on psychology
en.wikipedia.org/wiki/Flow_(psychology) educate yourself, fuckface