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

  • Home
  • SEARCH
  • 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 8403177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:16:23+00:00 2026-06-09T22:16:23+00:00

I’m writing a code that needs to run on a server using an old

  • 0

I’m writing a code that needs to run on a server using an old version of python (2.4?) with Numeric instead of numpy, I can’t do anything about that. To test the code, I run it with numpy.oldnumeric

I start with an array of float32’s, and I store values to them. My values are in the 1.0e50-1.0e60 range, and the array keeps storing them as ‘inf’. Even casting a 1.0e39, leads to ‘inf’. Aren’t floats supposed to max out closer to 1.0e108 ?! How can I preserve these values?

....
import numpy.oldnumeric as N
data = N.zeros(10, 'f')
....
for i in range(10): data[i] = (1.0e38)*pow(10.0,i)
print data[i]

gives

[  9.99999993e+36   9.99999968e+37              inf              inf
          inf              inf              inf              inf
          inf              inf]

Solution:
Single precision float (float32) is has a smaller limit than I thought (~3e38), thanks @aka.nice, so I switched from ‘f’ (float32) to ‘dtype=N.float64’, which has enough capacity.

  • 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-09T22:16:24+00:00Added an answer on June 9, 2026 at 10:16 pm

    You are using single precision floats…
    In IEEE 754 single precision, the limit of exponent is 127, giving a max float value of about 2 * 2^127, that is approximately

    2^10 > 10^3
    2^120 > 10^36
    2^127 > 2^7*10^36
    2^127 > 100*10^36
    2^127 > 10^38
    

    or 3.40282346×10^38 see http://en.wikipedia.org/wiki/IEEE_754

    The exact value is 2^128 – 2^104 = 340282346638528859811704183484516925440

    Use IEEE 754 double precision (64 bits), the limit is 2^1024-2^971, that is about 1.7976931348623157e308

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.