Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7706249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:04:43+00:00 2026-06-01T00:04:43+00:00

The Joy of Clojure says not to rationalize values that are Java float or

  • 0

“The Joy of Clojure” says not to rationalize values that are Java float or double primitives.

Why not rationalize them but it is ok to rationalize instances of java.lang.Float and java.lang.Double?

[EDIT]
The book (page 67) doesn’t suggest it is ok to rationalize java.lang.Float or java.lang.Double but it shows an example:

(def a (rationalize 1.0e50))
(def b (rationalize -1.0e50))
(def c (rationalize 17.0e00))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:04:44+00:00Added an answer on June 1, 2026 at 12:04 am

    So, is there a difference between rationalizing a double v.s. a Double (or a float v.s. a Float)? No, not really. You’re going to end up with a Ratio object in either case, and you’re going to have the same performance characteristics when doing lots of math on that type.

    e.g.

    user=> (class (rationalize 0.56))
    clojure.lang.Ratio
    user=> (class (Double. 0.56))
    java.lang.Double
    user=> (class (rationalize (Double. 0.56)))
    clojure.lang.Ratio
    

    Still though, if you need that sort of accuracy, then that would be the way to go. But if you can use standard computer floating point arithmetic, then you’ll be better off because this will translate much more directly into machine instructions than working with Ratio objects will.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a stupid question, but not having much joy researching it myself.
I've tried to search for a solution for this, but have had no joy:
2 days I've been trying to get my head around this, but no joy.
I have been working on this problem for a while but still no joy.
So, Erlang is a real joy to work with, but there's one problem I
I need to create a plug-in (with GUI) for an application that loads them
I was following The Joy of Clojure and I am puzzled with these 2
I have tried all the suggestions below but still no joy. I'm now trying
Hey guys, looked at the php docs and googled around, but no joy. This
In the book The Joy of Clojure, defprotocol is offered as a solution to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.