3 ms·
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 tha
by ComSubVie 2y ago
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)?
- actionfromafar 2y agoMaybe 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/ https://mpmath.org/
- haspok 2y agoYou 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".
- bajsejohannes 2y agoI 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".
- dsego 2y agoMaybe 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.
- dismalaf 2y agoSome programming languages differentiate between floats and decimals. But yeah, for laypeople, a float is a decimal.
- 3836293648 2y agoVery 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.