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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:36:16+00:00 2026-06-17T18:36:16+00:00

Answering one question Why does scipy.stats.nanmean give different result from numpy.nansum? , I realized,

  • 0

Answering one question Why does scipy.stats.nanmean give different result from numpy.nansum?, I realized, multiplying numpy.int32 by a float results in different float result compared to a Python POD int with a float.

Is there a reason to cause a float approximation when using numpy.int32

>>> numpy.int32(1) * 0.2
0.20000000000000001
>>> 1 * 0.2
0.2
  • 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-17T18:36:18+00:00Added an answer on June 17, 2026 at 6:36 pm

    The two expressions give results that are identical in value but have different types:

    In [17]: numpy.int32(1) * 0.2 == 1 * 0.2
    Out[17]: True
    
    In [18]: type(numpy.int32(1) * 0.2)
    Out[18]: numpy.float64
    
    In [19]: type(1 * 0.2)
    Out[19]: float
    

    The different output is purely due to the difference in default formatting between numpy.float64 and float.

    If we reverse the types, the output also reverses:

    In [12]: float(numpy.int32(1) * 0.2)
    Out[12]: 0.2
    
    In [13]: numpy.float64(1 * 0.2)
    Out[13]: 0.20000000000000001
    

    It’s purely a display issue. There is no numerical difference here.

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

Sidebar

Related Questions

Just like in SO, where one is answering a question, if somebody has answered
I was just answering a question about different approaches for picking the partition in
While answering one of the question, I came across this interesting situation. If I
Thanks to Insin for answering a previous question related to this one. His answer
Answering another question about how const string data was stored in an executable a
In answering another question, someone showed me the following tutorial, in which the author
Before answering, it is not as easy question as you might have thought about
In answering this code golf question , I ran across a problem in my
After answering a question about how to force-free objects in Java (the guy was
In answering another persons question here on SO, I discovered that there is a

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.