I'm trying to get what floating point is really good or necessary for, then. Would it be something like "huge or tiny scale, generally theoretical, scientific things?"
You only start to see errors after a while, and it is likely good enough for the calculations being done. For something like money, you need to be very exact since 0.123541234123 cents is not a real value. Every trade you might "lose some cents" eg 0.00000001 or something like that. Over billions of transactions that starts to build up, and you start to either create or lose money arbitrarily.
In finance, if you are keeping track of money you want to use integer values where at all possible.
Most real numbers cannot be presented exactly, including most decimals and some larger (positive) integers.
The smallest such integer in single-precision floating point is 16777217. This number cannot be represented exactly: the next floating point number after 16777216 is 16777218. Above that number you can no longer represent whole numbers.
Even at one decimal place of precision most numbers cannot be represented exactly. For example, 0.1, 0.2, 0.3 and 0.4 cannot and 0.5 is the first positive number that can be.
At two decimal places, there are virtually no numbers that can be represented exactly (0.25 is the first one that can be), so there's always some error and therefore the possibility of rounding errors. Even if you accept that, after 131072.01, some numbers cannot be represented exactly at all even with rounding: 131072 can be represented exactly, but the next number is 131072.015625 which rounds to 131072.02. No single-precision floating point numbers round to 131072.01.
Of course I'm using single-precision floating point here. These same problems exist for double-precision but at much larger numbers: the first integer that cannot be represented in double-precision is 9007199254740993. Either way, using floating point exposes you to the risk of errors in your calculations.
Hope that helps.
my question however was about functionally, when is it advised not to you floating point arithmetic.
The proposed solution is to never mess with division in the first place when computing P&L; operate on "total" values: cost basis, total profit, ....
Edit: and as a super minor point of contention, I don't think it's wrong to call it a technical difficulty. You can represent the involved quantities exactly with a decimal ratio type, and the existence of a technical solution indicates that the problem is at least somewhat technical in nature.
Now you sell 2 of them for $20 each ($40 in total), and have 1 share remaining. You want to calculate realized P&L using the average cost method. The average cost per share is $20/3, so the P&L is $40-(20/3).
Using average price and floating point imprecision are two separate, unrelated issues. You don't have to, and probably shouldn't use floating point to calculate the average price, and it's perfectly possible to use decimal arithmetic or fractions rather than floating point.
The real issue here is that 2/3 does not have a decimal representation, not floating point imprecision. No matter what you do, if you need to express it as a decimal of finite length it will need to be rounded, and that's where the imprecision is. In practice, you can generally get away with using floats because the floating point error ends up being less than the rounding imprecision.