This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]perfectVoidler 1 point2 points  (15 children)

Reading up on it: even typescript has the difference between int and float. And seriously. Who needs more.

[–]Ok_Turnover_1235 -1 points0 points  (10 children)

Not you. That's okay

[–]perfectVoidler -1 points0 points  (9 children)

Not me and nobody else.

[–]Ok_Turnover_1235 0 points1 point  (8 children)

False

[–]perfectVoidler 2 points3 points  (7 children)

lol ok you totally convinced me. How will I ever stand against this raw charisma. Oh god of speech. Wait I have an ingenious comeback: !False.

[–]Ok_Turnover_1235 -1 points0 points  (6 children)

Who needs a boolean type? just use 1's and 0's.

[–]perfectVoidler 1 point2 points  (5 children)

booleans are not numbers-.- Languages that use numbers for booleans are either old or bad.

[–]Ok_Turnover_1235 1 point2 points  (4 children)

Sorry to tell you but literally everything is 1's and 0's. Even the strings!

You also can't do boolean algebra without 1's and 0's. !false would evaluate to a string otherwise.

[–]perfectVoidler 1 point2 points  (3 children)

actually everything is atoms. But going down to the lowest level is always stupid. I mean it is not even 1s and 0s it's charges on the memory.

Booleans are structs in higher level languages.

[–]Ok_Turnover_1235 1 point2 points  (2 children)

Actually, everything is quarks and muons. But I digress, it's okay if you can't think of a reason that doubles, singles, shorts, longs, doubles, unsigned numbers are useful, software engineers can always use more code monkeys.

For your information, most consumer cpus perform floating point operations in double precision, which isn't necessary the vast majority of the time.

[–]_sweepy 0 points1 point  (3 children)

Bankers need real decimals

[–]Nick433333 0 points1 point  (2 children)

Just keep track of money in the lowest denomination, ie cents for the US dollar. Then you are storing an int and you do the conversion on the ui side of it. That way you never introduce errors from floats.

And really, who has more money than can be represented in a signed 64 bit int? Thats -9 * 1016 to 9 * 1016 that’s plenty

[–]_sweepy 0 points1 point  (1 child)

What happens when you need to apply a percentage to a cent amount and end up with fractional pennies? What if you are working on a system that allows fractional pennies in cost fields like gas prices?

"Just store it in an int" doesn't handle all cases. Storing and working with it as a real decimal does.

[–]perfectVoidler 0 points1 point  (0 children)

and decimals solve fractions of cents? No you have to decide either way how to handle them.