News for hackers. Stuff that matters.
Re:Understanding the Odin Programming Language by ComSubVie on Wednesday December 11, 2024 @09:59AM (#42388382)
What do you mean? It's exactly that in almost any programming language.

What is it you don't understand: "method" (a representation) or "decimal" (a number that consists of a whole and a fractional part)?

Re:Understanding the Odin Programming Language by bajsejohannes on Wednesday December 11, 2024 @11:20AM (#42389339)
I agree with OP that it's unnecessarily confusing. A "method" is a procedure. The floating point number is the result of that procedure, not the procedure itself.

"Decimal" implies a ten based system, even though it's perfectly fine to say "binary decimal".

Using your own replacement words, it would be clearer to write "A floating point number is a representation of a number with a fractional part".

Re:Understanding the Odin Programming Language by dsego on Wednesday December 11, 2024 @04:50PM (#42393372)
Maybe it should've said "is a method of storing" instead of "for". It would make it clear it's not talking about a procedure, but a way or manner of doing something.
Re:Understanding the Odin Programming Language by actionfromafar on Wednesday December 11, 2024 @10:34AM (#42388787)
Maybe OP reacted because a float only looks like it is a way to store decimal numbers, when it's only an approximation of decimal numbers. If you really need decimal numbers you need something like mpmath¹.

As a shorthand to explain what a float is to someone, "a decimal number" is an OK start though.

But sometimes that approximation breaks down even for simple examples, i.e. 0.1 cannot be represented as a float. This can be quite unexpected if your mental model is that "floats are decimal numbers with a certain precision".

1: https://mpmath.org/

Re:Understanding the Odin Programming Language by haspok on Wednesday December 11, 2024 @10:42AM (#42388867)
You cannot represent an arbitrary or fixed precision decimal number in a floating point format. Or to put it in another way:

"Most decimal fractions cannot be represented exactly as binary fractions." - from the Python tutorial

The word "decimal" does not simply mean "a number that consists of a whole and a fractional part".

Re:Understanding the Odin Programming Language by dismalaf on Wednesday December 11, 2024 @12:05PM (#42389983)
Some programming languages differentiate between floats and decimals. But yeah, for laypeople, a float is a decimal.
Re:Understanding the Odin Programming Language by 3836293648 on Wednesday December 11, 2024 @09:55PM (#42395747)
Very few numbers have decimals. They're not just numbers with whole and fractional parts, decimals are base 10 as well. .NET has them for monetary uses but I'm unaware of any other language(family) that has them built in.