*** saidinesh5 has quit IRC | 00:01 | |
*** saidinesh5 has joined #maemo | 00:01 | |
*** Venemo has joined #maemo | 00:04 | |
*** xes has quit IRC | 00:09 | |
*** xes has joined #maemo | 00:10 | |
*** Venemo has quit IRC | 00:34 | |
*** Kabouik has joined #maemo | 00:37 | |
*** Kilroo has joined #maemo | 00:42 | |
*** Pali has quit IRC | 01:13 | |
*** Kabouik has quit IRC | 01:18 | |
*** florian has quit IRC | 01:29 | |
*** xmn has joined #maemo | 01:31 | |
*** infobot has quit IRC | 01:38 | |
*** infobot has joined #maemo | 01:44 | |
*** ChanServ sets mode: +v infobot | 01:44 | |
*** freemangordon has quit IRC | 02:14 | |
*** jon_y has quit IRC | 02:33 | |
*** jon_y has joined #maemo | 02:34 | |
*** infobot has quit IRC | 03:16 | |
*** infobot has joined #maemo | 03:17 | |
*** ChanServ sets mode: +v infobot | 03:17 | |
*** drrty has quit IRC | 05:01 | |
*** drrty has joined #maemo | 05:01 | |
*** saidinesh5 has quit IRC | 05:13 | |
*** saidinesh5 has joined #maemo | 05:14 | |
*** BitEvil has joined #maemo | 05:24 | |
*** SpeedEvil is now known as Guest46477 | 05:24 | |
*** Kilroo has quit IRC | 06:23 | |
*** tm has quit IRC | 06:46 | |
*** tm has joined #maemo | 06:49 | |
*** pagurus has quit IRC | 06:56 | |
*** pagurus has joined #maemo | 06:57 | |
*** LauRoman has joined #maemo | 07:39 | |
*** freemangordon has joined #maemo | 08:15 | |
*** sunshavi has quit IRC | 08:45 | |
*** Pali has joined #maemo | 09:54 | |
*** eMHa_ has quit IRC | 10:00 | |
*** Pali has quit IRC | 10:08 | |
*** xmn has quit IRC | 10:35 | |
*** bleb is now known as bleb_ | 10:48 | |
*** bleb_ has quit IRC | 10:59 | |
*** bleb_ has joined #maemo | 10:59 | |
*** bleb has joined #maemo | 11:08 | |
*** saidinesh5 has quit IRC | 11:13 | |
*** saidinesh5 has joined #maemo | 11:14 | |
*** florian_kc has joined #maemo | 11:14 | |
*** Venemo has joined #maemo | 11:14 | |
*** Venemo has quit IRC | 11:14 | |
*** jskarvad has joined #maemo | 11:26 | |
*** drrty has quit IRC | 11:29 | |
*** drrty has joined #maemo | 11:29 | |
*** florian_kc is now known as florian | 11:33 | |
*** Venemo has joined #maemo | 11:52 | |
*** Venemo has quit IRC | 11:55 | |
*** peetah has quit IRC | 11:56 | |
*** bleb has quit IRC | 12:06 | |
*** bleb has joined #maemo | 12:06 | |
*** bleb_ has quit IRC | 12:10 | |
*** Venemo has joined #maemo | 12:11 | |
*** Kabouik has joined #maemo | 13:02 | |
*** BitEvil is now known as SpeedEvil | 13:55 | |
*** saidinesh5 has quit IRC | 14:13 | |
*** saidinesh5 has joined #maemo | 14:13 | |
*** sunshavi has joined #maemo | 14:39 | |
*** Pali has joined #maemo | 14:43 | |
brolin_empey | Maxdamantus: GNU bc, at least when run with the -l (--mathlib) option, seems to return the expected results without doing anything special. I have known of bc for probably at least fifteen years but may have never seriously tried using it until now, after I redd the complete https://en.wikipedia.org/wiki/Bc_(programming_language) article. | 15:21 |
---|---|---|
Maxdamantus | brolin_empey: okay, I didn't read your initial comment, but having read it now, the issue is not floating point, but binary representation of certain numbers. | 15:23 |
Maxdamantus | 19:45:35 < brolin_empey> Floating point arithmetic is strange? With CPython 2.7.x on Windows NT on x86-64 (Intel Core 2), Linux on ARM on both the Nokia N900 and LG G5, 4.18+2.61 returns 6.789999999999999 or similar instead of 6.79 and 6.79+8.59 returns 15.379999999999999 or similar instead of 15.38 . | 15:23 |
Maxdamantus | neither 4.18 nor 2.61 is representable in binary without using recurrence. | 15:24 |
Maxdamantus | bc isn't limited to binary numbers, so does not suffer conversion issues. | 15:24 |
Maxdamantus | eg, when you add 4.18 and 2.61, it just does the addition in decimal. | 15:25 |
Maxdamantus | when you evaluate the expression `4.18` as a binary float, it comes up with a value that is not exactly 4.18, but is a close approximation to it, and the usual binary float printing mechanisms will figure out that that number is very close to the decimal "4.18" when printing. | 15:26 |
Maxdamantus | particularly, `4.18` in all of those languages will be interpreted instead as `4.17999999999999971578290569595992565155029296875` | 15:27 |
Maxdamantus | if you try writing that number in any of those languages, the printer will round it back to 4.18. | 15:28 |
Maxdamantus | note that IEEE-754 includes definitions of both "binary" floats and "decimal" floats, though programming languages usually only support binary. | 15:30 |
brolin_empey | I think I may have known some of this stuff at least a decade ago but forgot it because I ended up being more of a sysadmin than a software developer. | 15:30 |
Maxdamantus | also note that decimal floats suffer the same issues, just with different sets of numbers. It happens that any number representable in binary is also representable in decimal, but a number like 1/3 is not representable in either. In decimal, you have to approximate 1/3 as something like `0.333333333333`, meaning (1/3)*3 will be something like `0.99999999999` | 15:31 |
Maxdamantus | (in base 3, that number is trivially representable as just `0.1`) | 15:31 |
Maxdamantus | fwiw, I don't think most developers understand this stuff. | 15:36 |
KotCzarny | most developers live by the motto 'good enough [tm]' | 15:37 |
Maxdamantus | Maybe a lot of them are aware that `0.1 + 0.2` is not `0.3`, but I suspect most of those people think the problem is in the addition, not in the representation. | 15:37 |
Maxdamantus | (to clarify, the addition works perfectly fine there; the problem is that none of the numbers `0.1`, `0.2` or `0.3` are representable in binary, so it's a bit like interpreting `1/3` as `0.3333` and calculating that `(1/3)*3 = 0.9999`) | 15:39 |
Maxdamantus | a related point that I find annoying: people often seem to think that the solution to this problem is for programming languages to provide decimal floats rather than just binary floats, but in cases where it actually matters, you pretty much never want decimal floats. | 16:02 |
*** Kabouik has quit IRC | 16:02 | |
Maxdamantus | in cases where it matters, you usually want either some sort of fixed-point decimal, or arbitrary-precision decimal, or unbounded rationals. | 16:03 |
Maxdamantus | Floating point overall is just a convenient way of providing generic operations for handling approximate values. If you're not willing to approximate, you shouldn't be using floats. | 16:04 |
* Maxdamantus sleeps. | 16:04 | |
KotCzarny | there are doubles for more decimal points accuracy | 16:04 |
Maxdamantus | You're probably thinking of a form of decimal floating point, like IEEE-754 decimal64 or decimal128 or something. | 16:05 |
Maxdamantus | and my point applies: if those are useful to you, your cases should be handled just as well, and probably even better, by using fixed-point decimals. | 16:06 |
KotCzarny | nah, just expanding byte count makes it goodier enough | 16:07 |
Maxdamantus | Unless you expand the byte count to infinity, you're still not going to get `0.1 + 0.2 == 0.3` | 16:08 |
* Maxdamantus really sleeps. | 16:08 | |
KotCzarny | ya, it's about setting your 'good enough' threshold | 16:09 |
*** sunshavi has quit IRC | 16:13 | |
*** jskarvad_ has joined #maemo | 16:45 | |
*** jskarvad has quit IRC | 16:48 | |
*** peetah has joined #maemo | 16:50 | |
*** florian_kc has joined #maemo | 16:55 | |
*** eMHa_ has joined #maemo | 16:57 | |
*** jskarvad_ has quit IRC | 16:58 | |
*** jskarvad has joined #maemo | 16:59 | |
*** florian_kc has quit IRC | 17:00 | |
*** sunshavi has joined #maemo | 17:11 | |
*** Venemo has quit IRC | 17:15 | |
*** eMHa_ has quit IRC | 17:23 | |
*** Venemo has joined #maemo | 17:36 | |
*** Venemo has quit IRC | 18:09 | |
*** Venemo has joined #maemo | 18:24 | |
*** Venemo has quit IRC | 18:38 | |
*** Venemo has joined #maemo | 18:46 | |
*** Venemo has quit IRC | 19:00 | |
*** jskarvad has quit IRC | 19:07 | |
*** xmn has joined #maemo | 19:37 | |
*** i336 has quit IRC | 19:38 | |
*** i336 has joined #maemo | 19:40 | |
*** florian has quit IRC | 20:24 | |
*** eMHa_ has joined #maemo | 21:08 | |
*** sunshavi has quit IRC | 21:09 | |
*** florian_kc has joined #maemo | 21:28 | |
*** sunshavi has joined #maemo | 21:41 | |
*** eMHa_ has quit IRC | 21:46 | |
*** peetah has quit IRC | 22:06 | |
*** peetah has joined #maemo | 22:07 | |
*** florian_kc is now known as florian | 22:10 | |
*** Kabouik has joined #maemo | 22:42 | |
*** Kabouik has quit IRC | 22:47 | |
*** saidinesh5 has quit IRC | 22:55 | |
*** saidinesh5 has joined #maemo | 22:56 | |
*** eMHa_ has joined #maemo | 23:41 |
Generated by irclog2html.py 2.15.1 by Marius Gedminas - find it at mg.pov.lt!