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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:58:35+00:00 2026-06-05T11:58:35+00:00

I am quite confused by dtype when creating numpy array. I am creating them

  • 0

I am quite confused by dtype when creating numpy array. I am creating them from a list of floats. First let me note that is not an issue of printing, becuase I already did: np.set_printoptions(precision=18).

This is a part of my list:

In [37]: boundary
Out[37]: 
[['3366307.654296875', '5814192.595703125'],
 ['3366372.2244873046875', '5814350.752685546875'],
 ['3366593.37969970703125', '5814844.73492431640625'],
 ['3367585.4779052734375', '5814429.293701171875'],
 ['3367680.55389404296875', '5814346.618896484375'],
 ....
 [ 3366307.654296875     ,  5814192.595703125     ]]

Then I convert it to a numpy array:

In [43]: boundary2=np.asarray(boundary, dtype=float)   
In [44]: boundary2
Out[44]: 
array([[ 3366307.654296875     ,  5814192.595703125     ],
       [ 3366372.2244873046875 ,  5814350.752685546875  ],
       [ 3366593.37969970703125,  5814844.73492431640625],
        ....
       [ 3366307.654296875     ,  5814192.595703125     ]])
# the full number of significant digits is preserved. 
# this also works with:
In [45]: boundary2=np.array(boundary, dtype=float)

In [46]: boundary2
Out[46]: 
array([[ 3366307.654296875     ,  5814192.595703125     ],
     [ 3366372.2244873046875 ,  5814350.752685546875  ],
     [ 3366593.37969970703125,  5814844.73492431640625],
     ...
     [ 3366307.654296875     ,  5814192.595703125     ]])

# This also works with dtype=np.float
In [56]: boundary3=np.array(boundary, dtype=np.float)
In [57]: boundary3
Out[57]: 
array([[ 3366307.654296875     ,  5814192.595703125     ],
       [ 3366372.2244873046875 ,  5814350.752685546875  ],
       [ 3366593.37969970703125,  5814844.73492431640625],
       ....
       [ 3366307.654296875     ,  5814192.595703125     ]])

Here is why I am confused, if I used dtype=np.float32 it seems like I loosing significant digits:

In [58]: boundary4=np.array(boundary, dtype=np.float32)   
In [59]: boundary4
Out[59]: 
array([[ 3366307.75,  5814192.5 ],
       [ 3366372.25,  5814351.  ],
       [ 3366593.5 ,  5814844.5 ],
       [ 3367585.5 ,  5814429.5 ],
       ...
       [ 3366307.75,  5814192.5 ]], dtype=float32)

The reason I say it seems is because apparently the arrays are the same. I can’t see the data directly, but checking with np.allclose returns True:

In [65]: np.allclose(boundary2, boundary4)
Out[65]: True

So, if you read so far, I hope you see why I am confused, and maybe there someone who can answer the following 2 questions:

  1. Why is dtype=float32 “hiding” my data ?
  2. Should I be concerned about it or I can safely continue using dtype=float?
  • 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-05T11:58:37+00:00Added an answer on June 5, 2026 at 11:58 am

    All floating point types have limited precision. The number of significant digits they can store depends on the number of bits in the floating point type. If you provide float, numpy.float or numpy.float64 as dtype, 64 bits are used (“double precision”), resulting in about 16 significant decimal digits. For numpy.float32, 32 bits are used (“single precision”), resulting in about 8 significant decimal digits. So nothing is “hidden”, you simply see the effects of limited floating point precision. numpy.allclose() returns True because all values are close within the limits of the floating point type you chose.

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

Sidebar

Related Questions

In URL rewriting, i am quite confused that should i use underscore (_) OR
I am quite confused with JSON, I can easily take first level arrays values,
I'm taking a course that is requiring the use of Checkstyle. I'm quite confused
I am quite confused with technique that I am using. I am using EditorFor
Im quite confused that what is difference between these two initializations: int (*p)[10]; and
I am getting quite confused with different opinion from diff people and the developer
I'm creating a theatre booking system. I am quite confused on how I can
I'm quite confused about several books in .NET that I have read. Would someone
So I am quite confused. I have a public string() array defined, and each
I am quite confused as I thought that ^ in regular expressions negated the

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.