On 11 Aug 2018, at 11:33, Pablo Rodriguez
wrote: On 08/09/2018 10:20 PM, Hans Åberg wrote:
On 9 Aug 2018, at 21:20, Pablo Rodriguez wrote: [...] My background is in humanities and I don’t understand the exponent for being a float ("10²" contains an exponent [https://www.m-w.com/dictionary/exponent], but I would say is an integer in all possible worlds [or all the worlds I know ]).
It may refer to a floating point number syntax as in C++ [1], where the three cases top there say that there must be a point '.' preceded or followed by at least one digit, or at least one digit followed by an exponent starting with 'e' or 'E'.
Many thanks for your explanation, Hans.
You are welcome.
I thought there should be some kind of restriction when referring to the exponent, but this is why technical explanations aren’t always very clear. I mean, they have too many restrictions attached to them.
The C++ description allows for fast reading with just one lookahead character at a time, which is was important in C when it appeared in 1972 on the not so powerful computers of the day. Then roundoff may make floating point numbers look like integers even they are not. For example, 1.0 could be 0.99999999 or 1.0000001. So don't check floating numbers for equality, instead use say abs(x - y) < a for some small number a. When adding exact integers and inexact floating point numbers, it is easiest to always make that inexact numbers, as exactness cannot always be guaranteed.