Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
alyx17199yExcept (int)foo is equivalent to floor(foo), so it would round 4.7 down to 4.
Typically 4.5 would be rounded up by a round(foo) function, but (as I just found out) it seems that C# rounds it down...?! -
Sykoah7119y@alyx It was a lazy response as my gf doesnt know anything about coding (I was hoping she would say "so I round down?") But she just said do it properly so I did. She is still confused. -
alyx17199yActually, scratch that, casts and floors are only equivalent for positive numbers. For negative numbers, floor rounds down while a cast rounds up. -
BartBB6849yCasts get rid of the floating point. They do technically round it to a full number, but the point is that it doesn't try to round up or down, just leave the number before the decimal point @alyx -
BartBB6849yWas looking for that word, but couldn't remember it, so I explained it instead xD @BearishMushroom -
alyx17199y@LucaScorpion I didn't believe you. So I tested it. And oh my god the last 9 years of my life are a lie D:
wtf, C#?! -
@alyx There's actually a good reason for it. From wikipedia: "This method treats positive and negative values symmetrically, and is therefore free of sign bias."
https://en.wikipedia.org/wiki/... -
Sykoah7119y@LucaScorpion Came to tell the good people of devrant my story of being an asshole. Got my mind blown instead lol. Ty for the trivia.
Related Rants

to great not to share.
I mean, we all have been there...
Gf: Which way do you round 4.5 up or down?
Me: (int)4.5;
Gf: Ffs the proper way!
Me: Math.Round(4.5);
Gf: Fuck off.
undefined
relationships
dev problems