coding in c until I go completely insane

coding in c until I go completely insane

Low Level Learning

1 год назад

1,533,454 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

- 13.11.2023 04:58

(1+2)/10
trolled

Ответить
Adi AlwaysUp
Adi AlwaysUp - 13.11.2023 03:16

The IEEE flag for compilers is a lifesaver. Coming for someone who writes scientific applications on supercomputers, it's a pain in the a$$

Edit: Forgot about 17 digits. You'd need 16 bytes then. So long double should work.

Ответить
Deepak Kumar
Deepak Kumar - 11.11.2023 20:39

Meanwhile Excel =SUM() function done this peacefully 😆😆

Ответить
Daniel Survivor
Daniel Survivor - 08.11.2023 17:31

Song name at the end?

Ответить
BryceBlazeGaming YT
BryceBlazeGaming YT - 05.11.2023 04:23

bro just use a double :sob:

Ответить
ChrisRM2023
ChrisRM2023 - 04.11.2023 01:30

0.1 + 0.2 = 0.3

Ответить
Leonardo Henrique
Leonardo Henrique - 24.10.2023 14:56

1 attemp only: I guess that the final 4 is something about the bits (is a float number, then it has 4 bits of lenght)

Ответить
Vikram Chatterjee
Vikram Chatterjee - 24.10.2023 03:37

Damn, that’s annoying.

Ответить
Noor
Noor - 23.10.2023 21:54

No wonder my conversion from farhenheit to celsius was wrong

Ответить
NICOLE NEW
NICOLE NEW - 19.10.2023 20:53

❤❤❤❤❤

Ответить
Vincent Chan
Vincent Chan - 18.10.2023 18:53

The reason is because of the floating point representation in computers. Since computers only store binary numbers some small errors are introduced when doing the conversions. If you want to learn more about it you can search IEEE 754 representation of floating points for starters.

Ответить
dvd b
dvd b - 18.10.2023 07:30

"Python help me out here" is such a mood 😂

Ответить
MichToJoshya
MichToJoshya - 17.10.2023 21:05

I actually suffered a similar bug in a production system that was supposed to work on really small percentages (which again blow up to be big after being multiplied by number of clients which ran in 100s of millions). This was in a big 3 software firms.
And I was a new hire.

Ответить
Alish
Alish - 15.10.2023 21:55

"Ohhh, whaatt the fuck" sounds too relatable

Ответить
Mateus
Mateus - 15.10.2023 00:26

Acho que consegui...

Ответить
Vlad3miRX
Vlad3miRX - 13.10.2023 19:09

What about to use long double. I know it's very implementation defined but why not to try?
For example, clang supports 128-bit long double on software level when using some compilation flag...

Ответить
[R@UL]
[R@UL] - 07.10.2023 07:03

What IDE do you use???

Ответить
Momentvm
Momentvm - 04.10.2023 19:21

IEEE-754, baby :). Try having fun with some floating point DSP code. Shout if you get a denormalized number ;)

Ответить
Lucas Augusto Sales Santos
Lucas Augusto Sales Santos - 03.10.2023 05:41

guy went ask help to Java LMAO

Ответить
Scover
Scover - 02.10.2023 09:15

Integers are your friend.
Just assume that integers are tenths.
1 + 2 = 3

Ответить
grass
grass - 01.10.2023 22:17

limited attempts is literally hell

Ответить
lapidations
lapidations - 30.09.2023 05:08

For my great suprise C# actually gets this one right.

Ответить
SGM Videos
SGM Videos - 28.09.2023 22:39

Now I'll be honest, you did one thing wrong, you used pure float in C, you should have gone with long double (128 bits).

Ответить
Artemis-Arrow
Artemis-Arrow - 28.09.2023 17:57

well, you could have used a more mathematical proof
1+2=3
so by dividing everything by 10
(1+2)/10=3/10
so, by printing the result of (1+2)/10, I thing you would have been able to get the level of accuracy you want, since it will be adding ints rather than floats

Ответить
Ofnir-1
Ofnir-1 - 28.09.2023 00:27

I just started learning how to code today, so I have no idea of what I just watched...I do know he fucked up tho😂

Ответить
Morton McCastle
Morton McCastle - 25.09.2023 06:29

Aren't Floats designed to be warped so it's more accurate closer to zero, and less accurate at super high numbers? But because of the warping, .1 + .2 would never actually equal .3, would it?

This challenge was impossible to begin with.

Ответить
Lord Vekk
Lord Vekk - 25.09.2023 02:01

why are you using argc and argv if you're not going to put any arguments in your program?

Ответить
Julian Ari
Julian Ari - 23.09.2023 13:26

Bro it's just a bonus, don't force javascript to do what it can't for just a bonus.

Ответить
Alejo Sanchez
Alejo Sanchez - 22.09.2023 03:25

float problem tho.

Ответить
Jason
Jason - 16.09.2023 00:39

Why « int argc, char **argv » in your « main » ? …

Ответить
Darko Bakula
Darko Bakula - 11.09.2023 22:59

Maybe mess around with compiler settings, study the floating point standard?

Ответить
Andre Kanara
Andre Kanara - 11.09.2023 15:22

You make coding fun again. Re ignited the fire in me. Thanks bro from christchurch new zealand. Chur

Ответить
BavovnaCat
BavovnaCat - 07.09.2023 16:46

IEEE 754 shenanigans be like

Ответить
Husk-ees
Husk-ees - 07.09.2023 04:49

insane? i was insane once. then they trapped me in a room. a rubber room. a rubber room with rats. the rats made me insane

Ответить
Xpressionless
Xpressionless - 07.09.2023 03:43

Well, you see...
0.30000001192092896, if rounded, will still be 0.3. So arguably, C answer is still correct.

Ответить
E Nsk
E Nsk - 05.09.2023 08:22

Use Ruby: "0.1".to_r + "0.2".to_r == "0.3".to_r
=> true
... Subscribed to save the sanity ¯\_(ツ)_/¯

Ответить
Dominionian
Dominionian - 23.08.2023 07:09

IEEE754 standard for finite precision floating point. In C, "float" is usually 32-bit single precision. For your 2nd and 3rd attempts, those were double precision.

Ответить
John Doe
John Doe - 18.08.2023 22:49

Easy. Just convert to a string, append more zero's and convert back to int.

Ответить
QuantumV
QuantumV - 18.08.2023 11:53

i find it funny that i only know why this happens because of an sm64 video

Ответить
Microtech BD System - Automation Engineering
Microtech BD System - Automation Engineering - 09.08.2023 22:55

Still now almost all hardware level programming done by either C or C++..
So my favourite language for bit Byte and register level Access...

Ответить
Timothy Chapman
Timothy Chapman - 23.07.2023 01:20

Should have used doubles or long doubles.

Ответить
Sollder 1
Sollder 1 - 16.07.2023 12:26

Java Masterrace would have saved you

Ответить
Edward Chan
Edward Chan - 11.07.2023 01:05

Tbh it's not really a C problem, inaccuracy is an inherent property of all floating points numbers... but it's fast so who cares?

Ответить
Adil Bougma
Adil Bougma - 08.07.2023 19:28

Computer can't do math because the memory is limited to 32 bit or 64 bit 😂😂

Ответить
TQ
TQ - 27.06.2023 07:24

Does anyone have the technical explanation of why this is the case?

Ответить
Etherous
Etherous - 25.06.2023 13:56

this thing won't work because in C floating-point numbers are represented using binary approximations
so you gotta use gmp or whatever, pick your poison buddy

Ответить
Glenn Hamblin
Glenn Hamblin - 24.06.2023 20:33

Printf your original answer and tack on (concantonate?) a string of 15 zeros.

Ответить