IRC log of #maemo for Tuesday, 2019-07-16

*** saidinesh5 has quit IRC00:01
*** saidinesh5 has joined #maemo00:01
*** Venemo has joined #maemo00:04
*** xes has quit IRC00:09
*** xes has joined #maemo00:10
*** Venemo has quit IRC00:34
*** Kabouik has joined #maemo00:37
*** Kilroo has joined #maemo00:42
*** Pali has quit IRC01:13
*** Kabouik has quit IRC01:18
*** florian has quit IRC01:29
*** xmn has joined #maemo01:31
*** infobot has quit IRC01:38
*** infobot has joined #maemo01:44
*** ChanServ sets mode: +v infobot01:44
*** freemangordon has quit IRC02:14
*** jon_y has quit IRC02:33
*** jon_y has joined #maemo02:34
*** infobot has quit IRC03:16
*** infobot has joined #maemo03:17
*** ChanServ sets mode: +v infobot03:17
*** drrty has quit IRC05:01
*** drrty has joined #maemo05:01
*** saidinesh5 has quit IRC05:13
*** saidinesh5 has joined #maemo05:14
*** BitEvil has joined #maemo05:24
*** SpeedEvil is now known as Guest4647705:24
*** Kilroo has quit IRC06:23
*** tm has quit IRC06:46
*** tm has joined #maemo06:49
*** pagurus has quit IRC06:56
*** pagurus has joined #maemo06:57
*** LauRoman has joined #maemo07:39
*** freemangordon has joined #maemo08:15
*** sunshavi has quit IRC08:45
*** Pali has joined #maemo09:54
*** eMHa_ has quit IRC10:00
*** Pali has quit IRC10:08
*** xmn has quit IRC10:35
*** bleb is now known as bleb_10:48
*** bleb_ has quit IRC10:59
*** bleb_ has joined #maemo10:59
*** bleb has joined #maemo11:08
*** saidinesh5 has quit IRC11:13
*** saidinesh5 has joined #maemo11:14
*** florian_kc has joined #maemo11:14
*** Venemo has joined #maemo11:14
*** Venemo has quit IRC11:14
*** jskarvad has joined #maemo11:26
*** drrty has quit IRC11:29
*** drrty has joined #maemo11:29
*** florian_kc is now known as florian11:33
*** Venemo has joined #maemo11:52
*** Venemo has quit IRC11:55
*** peetah has quit IRC11:56
*** bleb has quit IRC12:06
*** bleb has joined #maemo12:06
*** bleb_ has quit IRC12:10
*** Venemo has joined #maemo12:11
*** Kabouik has joined #maemo13:02
*** BitEvil is now known as SpeedEvil13:55
*** saidinesh5 has quit IRC14:13
*** saidinesh5 has joined #maemo14:13
*** sunshavi has joined #maemo14:39
*** Pali has joined #maemo14:43
brolin_empeyMaxdamantus: 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
Maxdamantusbrolin_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
Maxdamantus19: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
Maxdamantusneither 4.18 nor 2.61 is representable in binary without using recurrence.15:24
Maxdamantusbc isn't limited to binary numbers, so does not suffer conversion issues.15:24
Maxdamantuseg, when you add 4.18 and 2.61, it just does the addition in decimal.15:25
Maxdamantuswhen 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
Maxdamantusparticularly, `4.18` in all of those languages will be interpreted instead as `4.17999999999999971578290569595992565155029296875`15:27
Maxdamantusif you try writing that number in any of those languages, the printer will round it back to 4.18.15:28
Maxdamantusnote that IEEE-754 includes definitions of both "binary" floats and "decimal" floats, though programming languages usually only support binary.15:30
brolin_empeyI 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
Maxdamantusalso 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
Maxdamantusfwiw, I don't think most developers understand this stuff.15:36
KotCzarnymost developers live by the motto 'good enough [tm]'15:37
MaxdamantusMaybe 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
Maxdamantusa 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 IRC16:02
Maxdamantusin cases where it matters, you usually want either some sort of fixed-point decimal, or arbitrary-precision decimal, or unbounded rationals.16:03
MaxdamantusFloating 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
KotCzarnythere are doubles for more decimal points accuracy16:04
MaxdamantusYou're probably thinking of a form of decimal floating point, like IEEE-754 decimal64 or decimal128 or something.16:05
Maxdamantusand 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
KotCzarnynah, just expanding byte count makes it goodier enough16:07
MaxdamantusUnless 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
KotCzarnyya, it's about setting your 'good enough' threshold16:09
*** sunshavi has quit IRC16:13
*** jskarvad_ has joined #maemo16:45
*** jskarvad has quit IRC16:48
*** peetah has joined #maemo16:50
*** florian_kc has joined #maemo16:55
*** eMHa_ has joined #maemo16:57
*** jskarvad_ has quit IRC16:58
*** jskarvad has joined #maemo16:59
*** florian_kc has quit IRC17:00
*** sunshavi has joined #maemo17:11
*** Venemo has quit IRC17:15
*** eMHa_ has quit IRC17:23
*** Venemo has joined #maemo17:36
*** Venemo has quit IRC18:09
*** Venemo has joined #maemo18:24
*** Venemo has quit IRC18:38
*** Venemo has joined #maemo18:46
*** Venemo has quit IRC19:00
*** jskarvad has quit IRC19:07
*** xmn has joined #maemo19:37
*** i336 has quit IRC19:38
*** i336 has joined #maemo19:40
*** florian has quit IRC20:24
*** eMHa_ has joined #maemo21:08
*** sunshavi has quit IRC21:09
*** florian_kc has joined #maemo21:28
*** sunshavi has joined #maemo21:41
*** eMHa_ has quit IRC21:46
*** peetah has quit IRC22:06
*** peetah has joined #maemo22:07
*** florian_kc is now known as florian22:10
*** Kabouik has joined #maemo22:42
*** Kabouik has quit IRC22:47
*** saidinesh5 has quit IRC22:55
*** saidinesh5 has joined #maemo22:56
*** eMHa_ has joined #maemo23:41

Generated by irclog2html.py 2.15.1 by Marius Gedminas - find it at mg.pov.lt!