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 8580933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:55:54+00:00 2026-06-11T20:55:54+00:00

Why the false in the 2nd comparison? I am not loading any libraries. puts

  • 0

Why the false in the 2nd comparison? I am not loading any libraries.

puts RUBY_DESCRIPTION
t = Time.now
t1 = Time.at(t.to_f)
t2 = Time.at(t.to_f)
puts( t1 == t2 )
puts( t == t1 )
puts( t.to_f == t1.to_f )
printf "%.64f\n%.64f\n%.64f\n", t, t1, t2

Output:

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
true
false
true
1347661545.4348440170288085937500000000000000000000000000000000000000000000
1347661545.4348440170288085937500000000000000000000000000000000000000000000
1347661545.4348440170288085937500000000000000000000000000000000000000000000

I get all trues on 1.8.7. What’s going on?

I updated the script to show that the floats are the same, as far as I can tell. Am I missing something?

  • 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-11T20:55:56+00:00Added an answer on June 11, 2026 at 8:55 pm

    From the docs on Time.to_f: “Note that IEEE 754 double is not accurate enough to represent number of nanoseconds from the Epoch.” To illustrate @oldrinb’s comment:

    puts RUBY_DESCRIPTION # ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
    t = Time.now
    p t.subsec #=> (40189433/100000000); # a Rational, note the last digits 33
    p t.to_f   #=> 1347661635.4018943   # last digit missing 3
    

    Time#subsec documentation: “The lowest digit of #to_f and subsec is different because IEEE 754 double is not accurate enough to represent the rational. The accurate value is returned by subsec.”

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

Sidebar

Related Questions

return false seems to work in the submitHandler but I'm not sure why. function
On Firefox: console.log(document.createElement('input').placeholder === ''); // true console.log(document.createElement('input').hasOwnProperty('placeholder')); // false I think the 2nd
ghci> 4 == 3.9999999999999999 True ghci> 10.2^2 == 104.04 False Why the 2nd expression
I could not find an errata for the 2nd edition of this book. My
I use: [Obsolete(Use AnotherMethod() insted., false)] 2nd parameter is false but Visual Studio shows
TRUE/FALSE if clauses are easily and quickly done in R. However, if the argument
return false; for form submission is working for the rest of my code, just
[PersonListNav pushViewController:plist animated:FALSE];Hi there! :) Googling this has returned no luck... In short, I
Is UIObject#setVisible(false) functionally different from Widget#removeFromParent ? Besides, Is DialogBox#hide just a wapper call
bool hasDuplicate = false; int[] a = new int[] {1, 2, 3, 4}; int[]

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.