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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:41:04+00:00 2026-05-24T02:41:04+00:00

I’m running into an issue with python automatically rounding very small numbers (smaller than

  • 0

I’m running into an issue with python automatically rounding very small numbers (smaller than 1e-8) when subtracting an array from an single float. Take this example:

 import numpy as np
 float(1) - np.array([1e-10, 1e-5])

Any thoughts on how to force python not to round? This is forcing me to divide by zero in some cases, and becoming a problem. The same problem arises when subtracting from an numpy array.

  • 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-05-24T02:41:04+00:00Added an answer on May 24, 2026 at 2:41 am

    Mostly, it’s just the repr of numpy arrays that’s fooling you.

    Consider your example above:

    import numpy as np  
    x = float(1) - np.array([1e-10, 1e-5]) 
    print x
    print x[0]
    print x[0] == 1.0
    

    This yields:

    [ 1.      0.99999 ]
    0.99999999999
    False
    

    So the first element isn’t actually zero, it’s just the pretty-printing of numpy arrays that’s showing it that way.

    This can be controlled by numpy.set_printoptions.

    Of course, numpy is fundementally using limited precision floats. The whole point of numpy is to be a memory-efficient container for arrays of similar data, so there’s no equivalent of the decimal class in numpy.

    However, 64-bit floats have a decent range of precision. You won’t hit too many problems with 1e-10 and 1e-5. If you need, there’s also a numpy.float128 dtype, but operations will be much slower than using native floats.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.