3.What is output of following? (define a 97) (integer->char (exact->inexact a))
Reveal answer
Fill a bubble to check yourself
3.What is output of following? (define a 97) (integer->char (exact->inexact a))
#\97
#\b
#\a
Compile time error
integer->char expects an integer code (like 97 for #a). exact->inexact converts 97 to 97.0 (a float). integer->char cannot accept a float - it requires an exact integer. This causes a compile-time error.
exact->inexact converts the exact integer 97 into an inexact (floating-point) number, and integer->char requires an exact integer argument to map to a character. Passing an inexact number violates that type contract, so the call raises a compile/type error rather than producing a character like #\a.