Fork me on GitHub
#beginners
<
2016-08-16
>
saicheong06:08:23

@seancorfield: besides being new to Clojure, I'm also new to Slack. So when you said you added an example, I didn't know where to look for it. Now I know...😁 Hopefully the jdbc documentation can be updated soon.

seancorfield16:08:15

@saicheong: I updated the readme in the java.jdbc repo yesterday (and fixed the postgres / postgresql alias bug that confused both me and @josh_tackett — although that won’t be available until I release 0.6.2 Alpha 3 or whatever I call the next version). I’ll try to find time this week to update the http://clojure-doc.org documentation for java.jdbc (and then bug the maintainer to publish a new version of the site to include those changes).

mi-mina18:08:25

Hi Everybody! I have this code:

(def c [0.0 0.18 0.36 0.54 0.72])
(partition 2 1 c)
=> ((0.0 0.18) (0.18 0.36) (0.36 0.54) (0.54 0.72))
(map #(- (second %) (first %)) (partition 2 1 c))
=> (0.18 0.18 0.18000000000000005 0.17999999999999994)

mi-mina18:08:36

Does anyone know why from the third element onwards the result has so many decimals?

oahner18:08:52

that's IEEE floating points

chris18:08:50

a call to format will take care of this

val_waeselynck18:08:53

@mi-mina: this is not Clojure-specific; there is no exact representation of decimal numbers such as 0.18 as floats or doubles

mi-mina18:08:09

Oh, thanks!

chris18:08:21

but in general floating point math sucks and you shouldn’t use it if you require any semblance of precision

oahner18:08:27

the real question is, does your problem depend on those numbers being precise, or do you just want to round those numbers up?

val_waeselynck18:08:28

(btw this is why Clojure has Ratios)

mi-mina18:08:58

This is for a Kata. After I have the sections of c (the difference between one item and the next) and some other operations on the vector, I need to get the floor of the maximun section.

oahner18:08:15

format is definitely what you're looking for

oahner18:08:42

handling say, money, would have been a tiny bit more difficult

mi-mina18:08:25

Heheheh, thanks! I'm reading the formatdocs right now 😉