freenode/#lisp - IRC Chatlog
Search
19:53:09
krwq
what's the most generic specialization for strings in defgeneric? I've tried using just `string` but it seems that when element is #<(SIMPLE-ARRAY CHARACTER (3)) {10099D919F}> this doesn't worl
20:07:10
krwq
is there a way to force errors when generic functions are created implicitly when defmethod is used?
20:08:58
fourier
fe[nl]ix: I've fixed that you've requested in osicat pull requests(there are 2 from me), but there is something strange on travis - sbcl unable to install.. I guess
3:52:38
Zhivago
Above, you are printing one edge of that interval at some precision and assuming that it corresponds with the identity of the inteval, which is not true.
3:59:11
pierpa
try (decode-float 0.00002), (decode-float 0.00003), etc, then check references to understand what the results mean.
4:15:37
beach
fourroot: It is not that floating-point arithmetic is inexact. It isn't. At least not with IEEE floating point numbers. But, for a decimal fraction like the ones you give as examples, there is no exact binary floating point value for them, so you typically get the closest available one.
5:19:38
stacksmith
Your question makes no sense. '(+ 2 2) is a list. You could compile it, make a function, and run it - is that what you mean?
5:22:43
Digit
hi. (presumably) quick question, why does (- 9000 (* (round 9000 100) 99.99)) return 0.9003906, instead of just 0.9? ( same behaviour with s/round/floor|truncate|ceiling/ ) ~ poking around in ghci (which i'm similarly incompetent in), and i get the likes of "9000-8999.1" giving 0.8999999999996362. !? why's this madness not corrected? or is it correct, and i'm the one who's gone mad? srsly tho, there's a word for this, right? (to
5:23:59
stacksmith
floats don't always have an exact representation, so you get the nearest one. It is not a Lisp issue.
5:30:31
beach
It is interesting that people discover this problem only when they start using Common Lisp, having used floating point numbers with other languages for many years, without knowing how they work. This is very scary to me, because who knows how many professional developers have made software that is relied upon, but that is buggy?
5:33:02
beach
Most people never get to use Common Lisp, so they never discover the problem like this.
5:34:25
beach
My point is that people seem not to notice those problems with other languages, presumably because of the way those numbers are printed, with a limited precision.
5:35:19
beach
So, while, as I pointed out, the problems exists everywhere, it goes unnoticed even by professional developers using floating-point numbers in the software they write.
5:46:15
aeth
Other languages tend to default to double-float instead of single-float. The issues with floating point are more obvious in single-float.
5:49:24
aeth
(Combine that *with* rounding when printing, of course. The example still fails with double float, just more decimal points down.)
6:20:28
aeth
If you think in terms of counting cells: | 1 | 2 | 3 | 4 | 5 | (first, second, third, etc.), but if you think in terms of *offsets* from the start: | 0 | 1 | 2 | 3 | 4 | (i.e. add 0 to get to the first one, add 1 to get to the second, etc.)
6:22:19
Zhivago
Now imagine that you're transforming from two dimensional to one dimensional coordinates.
6:41:26
aeth
To translate what I think the article is saying into CL terms, compare the 1-based (let ((end 10)) (loop for i from 1 to end collect i)) to the 0-based (let ((end 10)) (loop for i from 0 below end collect i)) and they seem fairly equivalent, but how do you get an empty one? You set end to 0. Going "from 0 below 0" seems more intuitive than going "from 1 to 0".
6:44:50
aeth
i.e. dealing with the range "start <= i < end" instead of "start <= i <= end" makes more sense when it's empty