Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #reader(lib "htdp-advanced-reader.ss" "lang")((modname |33.2|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu ;overflow-n? : N -> N
5 12687dd9 2023-08-04 jrmu ;Searches for a value from [n,+inf.0) such that the number returned is the largest natural number where (expt #i10. n) is still an inexact number rather than infinity.
6 12687dd9 2023-08-04 jrmu
7 12687dd9 2023-08-04 jrmu (define (overflow-n? n)
8 12687dd9 2023-08-04 jrmu (cond
9 12687dd9 2023-08-04 jrmu [(< (expt #i10. (+ n 1)) +inf.0) (overflow-n? (add1 n))]
10 12687dd9 2023-08-04 jrmu [else n]))
11 12687dd9 2023-08-04 jrmu
12 12687dd9 2023-08-04 jrmu (overflow-n? 1)
13 12687dd9 2023-08-04 jrmu
14 12687dd9 2023-08-04 jrmu underflow-n? : integer -> integer
15 12687dd9 2023-08-04 jrmu ;Searches for a value from (-inf.0,n] such that the number returned is the smallest integer possible where (expt #i10. n) is still an inexact number rather than #i0
16 12687dd9 2023-08-04 jrmu
17 12687dd9 2023-08-04 jrmu (define (underflow-n? n)
18 12687dd9 2023-08-04 jrmu (cond
19 12687dd9 2023-08-04 jrmu [(> (expt #i10. n) #i0) (underflow-n? (sub1 n))]
20 12687dd9 2023-08-04 jrmu [else n]))