Re: [racket] HTDP 2nd edition exercise 4.2.3 - floating point issues

2013-10-22 Thread Bo Gus
(=~ is interesting. Thanks. On 22 October 2013 13:53, Matthias Felleisen wrote: > > ;; equation3 : number -> boolean > ;; to determine whether n is a solution for 2n^2 = 102 > (define (equation3 n) > (=~ (* 2 n n) 102 .001)) > > > -- Matthias > > > > On Oct 22, 2013, at 8:40 AM, Bo Gus

Re: [racket] HTDP 2nd edition exercise 4.2.3 - floating point issues

2013-10-22 Thread Matthias Felleisen
Hi BoGus, fwiw, this exercise is NOT in HTDP 2nd edition but HTDP 1st edition, 1-4th printing. Just in case you really want to work through HtDP 2e. -- Matthias On Oct 22, 2013, at 8:53 AM, Matthias Felleisen wrote: > > ;; equation3 : number -> boolean > ;; to determine whether n

Re: [racket] HTDP 2nd edition exercise 4.2.3 - floating point issues

2013-10-22 Thread Matthias Felleisen
;; equation3 : number -> boolean ;; to determine whether n is a solution for 2n^2 = 102 (define (equation3 n) (=~ (* 2 n n) 102 .001)) -- Matthias On Oct 22, 2013, at 8:40 AM, Bo Gus wrote: > equation 2 is 2n^2 = 102 so I implement like this: > > ;; equation3 : number -> boolean >

[racket] HTDP 2nd edition exercise 4.2.3 - floating point issues

2013-10-22 Thread Bo Gus
equation 2 is 2n^2 = 102 so I implement like this: ;; equation3 : number -> boolean ;; to determine whether n is a solution for 2n^2 = 102 (define (equation3 n) (= (* 2 n n) 102)) And my answer is the same as per the online answer. so great. But how can I check a valid answer. Eg if I do