Some related facts, but not sure if they offer a perfect justification for
_why_ rational? and decimal? return what they do.

(source rational?) reveals that it returns true for integers, ratios, and
decimal?, where (source decimal?) reveals it is true if it is of type
BigDecimal.  Arithmetic operations like + - * / quot rem given integers and
ratios should always return exact answers as other integers or ratios
(barring division by 0).  I don't think that is true for BigDecimal's,
though, at least with division.

Regarding rational numbers as ones that can be written as a fraction, all
float and double values except NaN, and positive and negative infinity can
be written exactly as fractions, too.  However, + - * / usually give only
approximate answers, not exact.

Andy

On Thu, Jun 11, 2015 at 6:39 PM, John Gabriele <jmg3...@gmail.com> wrote:

>
>
> On Thursday, June 11, 2015 at 9:34:57 PM UTC-4, John Gabriele wrote:
>
>>
>> ~~~
>> (integer? 5)   ;=> true     Yes
>> (integer? 5N)  ;=> true     Yes
>> (integer? 5.1) ;=> false
>>
>> (float? 5.1)  ;=> true
>> (float? 5.1M) ;=> false (?!)
>> ~~~
>>
>>
> Whoops. Please ignore the two "Yes"'s.
>
> Also, I think I just fell further into the rabbit hole:
>
> ~~~
> (rational? 5.1)  ;=> false
> (rational? 5.1M) ;=> true (?!)
>
> (decimal? 5.1)   ;=> false
> (decimal? 5.1M)  ;=> true (?!)
> ~~~
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to