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

The Archive Base Latest Questions

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

I want to save an array with floats to at file with numpy.savetxt(). The

  • 0

I want to save an array with floats to at file with numpy.savetxt().
The floats have to be decimals (so non-exponential!)

The code is as follows:

wav = 1./w
wav = np.array(sorted(wav))
efittet = permfitfuncLD(params1[0], params1[1:],1./wav).real
eefittet = permfitfuncLD(params1[0], params1[1:],1./wav).imag
etoprint = [float(s) for s in ["%.5f" % i for i in efittet]]
eetoprint = [float(s) for s in ["%.5f" % i for i in eefittet]]
wavtoprint = [float(s) for s in ["%.5f" % i for i in wav]]
print "--------------------------------------------------------------------"
print "etoprint"
print etoprint
print "--------------------------------------------------------------------"
print "eetoprint"
print eetoprint
print "--------------------------------------------------------------------"
print "wavtoprint"
print wavtoprint
print "--------------------------------------------------------------------"
arr = np.array([wavtoprint,etoprint,eetoprint]).transpose()
print "txt to safe should contain: ", arr

w and params are some parameters for my function permfitfuncLD() which itself is complex.
The output is:

--------------------------------------------------------------------
etoprint
[0.50391, 0.44551, 0.37837, 0.29117, 0.19734, 0.09081, -0.03854, -0.17022, -0.325, -0.47742, -0.63656, -0.8125, -0.9728, -1.13589, -1.26684, -1.36734, -1.42736, -1.42551, -1.3545, -1.23074, -1.07199, -0.90215, -0.79518, -0.78347, -0.899, -1.14185, -1.51655, -1.87591, -2.07595, -1.89561, -1.53701, -1.56583, -2.20596, -3.38828, -4.77624, -6.39743, -8.43319, -10.62524, -13.43619, -16.55797, -20.35308, -25.49629, -31.56653, -40.21232, -51.0312, -66.09163, -90.35934, -125.69555, -188.95742]
--------------------------------------------------------------------
eetoprint
[3.51955, 3.48008, 3.44968, 3.42508, 3.41183, 3.40951, 3.4217, 3.44898, 3.49899, 3.5671, 3.6595, 3.79075, 3.94391, 4.14716, 4.3697, 4.62296, 4.92274, 5.20694, 5.49578, 5.71423, 5.85755, 5.90724, 5.8566, 5.72561, 5.58159, 5.4753, 5.48067, 5.66307, 6.04179, 6.30754, 6.06509, 5.20939, 4.3096, 3.51667, 2.98072, 2.59107, 2.28845, 2.09188, 1.9525, 1.88784, 1.89048, 1.98989, 2.20993, 2.67266, 3.45841, 4.87942, 7.80959, 13.04591, 25.27873]
--------------------------------------------------------------------
wavtoprint
[0.18787, 0.19165, 0.19527, 0.19935, 0.20327, 0.20735, 0.21196, 0.2164, 0.22142, 0.22627, 0.23134, 0.23709, 0.24265, 0.24899, 0.25514, 0.2616, 0.26897, 0.27616, 0.2844, 0.29244, 0.30096, 0.31077, 0.3204, 0.33154, 0.34253, 0.35428, 0.36794, 0.38153, 0.39742, 0.41332, 0.43054, 0.4509, 0.47147, 0.49599, 0.52099, 0.54866, 0.58214, 0.6169, 0.65956, 0.70453, 0.75608, 0.82117, 0.89206, 0.9841, 1.08769, 1.21565, 1.39322, 1.61035, 1.93745]
--------------------------------------------------------------------
txt to safe should contain:  [[  1.87870000e-01   5.03910000e-01   3.51955000e+00]
 [  1.91650000e-01   4.45510000e-01   3.48008000e+00]
 [  1.95270000e-01   3.78370000e-01   3.44968000e+00]
 [  1.99350000e-01   2.91170000e-01   3.42508000e+00]
 [  2.03270000e-01   1.97340000e-01   3.41183000e+00]
 [  2.07350000e-01   9.08100000e-02   3.40951000e+00]
 [  2.11960000e-01  -3.85400000e-02   3.42170000e+00]
 [  2.16400000e-01  -1.70220000e-01   3.44898000e+00]
 [  2.21420000e-01  -3.25000000e-01   3.49899000e+00]
 [  2.26270000e-01  -4.77420000e-01   3.56710000e+00]
 [  2.31340000e-01  -6.36560000e-01   3.65950000e+00]
 [  2.37090000e-01  -8.12500000e-01   3.79075000e+00]
 [  2.42650000e-01  -9.72800000e-01   3.94391000e+00]
 [  2.48990000e-01  -1.13589000e+00   4.14716000e+00]
 [  2.55140000e-01  -1.26684000e+00   4.36970000e+00]
 [  2.61600000e-01  -1.36734000e+00   4.62296000e+00]
 [  2.68970000e-01  -1.42736000e+00   4.92274000e+00]
 [  2.76160000e-01  -1.42551000e+00   5.20694000e+00]
 [  2.84400000e-01  -1.35450000e+00   5.49578000e+00]
 [  2.92440000e-01  -1.23074000e+00   5.71423000e+00]
 [  3.00960000e-01  -1.07199000e+00   5.85755000e+00]
 [  3.10770000e-01  -9.02150000e-01   5.90724000e+00]
 [  3.20400000e-01  -7.95180000e-01   5.85660000e+00]
 [  3.31540000e-01  -7.83470000e-01   5.72561000e+00]
 [  3.42530000e-01  -8.99000000e-01   5.58159000e+00]
 [  3.54280000e-01  -1.14185000e+00   5.47530000e+00]
 [  3.67940000e-01  -1.51655000e+00   5.48067000e+00]
 [  3.81530000e-01  -1.87591000e+00   5.66307000e+00]
 [  3.97420000e-01  -2.07595000e+00   6.04179000e+00]
 [  4.13320000e-01  -1.89561000e+00   6.30754000e+00]
 [  4.30540000e-01  -1.53701000e+00   6.06509000e+00]
 [  4.50900000e-01  -1.56583000e+00   5.20939000e+00]
 [  4.71470000e-01  -2.20596000e+00   4.30960000e+00]
 [  4.95990000e-01  -3.38828000e+00   3.51667000e+00]
 [  5.20990000e-01  -4.77624000e+00   2.98072000e+00]
 [  5.48660000e-01  -6.39743000e+00   2.59107000e+00]
 [  5.82140000e-01  -8.43319000e+00   2.28845000e+00]
 [  6.16900000e-01  -1.06252400e+01   2.09188000e+00]
 [  6.59560000e-01  -1.34361900e+01   1.95250000e+00]
 [  7.04530000e-01  -1.65579700e+01   1.88784000e+00]
 [  7.56080000e-01  -2.03530800e+01   1.89048000e+00]
 [  8.21170000e-01  -2.54962900e+01   1.98989000e+00]
 [  8.92060000e-01  -3.15665300e+01   2.20993000e+00]
 [  9.84100000e-01  -4.02123200e+01   2.67266000e+00]
 [  1.08769000e+00  -5.10312000e+01   3.45841000e+00]
 [  1.21565000e+00  -6.60916300e+01   4.87942000e+00]
 [  1.39322000e+00  -9.03593400e+01   7.80959000e+00]
 [  1.61035000e+00  -1.25695550e+02   1.30459100e+01]
 [  1.93745000e+00  -1.88957420e+02   2.52787300e+01]]

My Problem is, that the values have to be floats (i.e the first one should be 0.18787).
I don’t understand, why the numbers in array arr have exponential form.

I really appreciate your help!

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

    These are floats. It is just another way to display floats. Numpy arrays print the floats in exponential format by default. If you need another format for storing the data in a text file, you have to use numpy.save.savetxt or do that yourself using the python formatting functions.

    However, you should be aware that you’re going to loose precision compared to the scientific format. The reason is that the scientific format can represent very small numbers in the same amount of digits as it can represent very high numbers. You cannot do that with the decimal representation.

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

Sidebar

Related Questions

I want to use numpy.savetxt() to save an array of complex numbers to a
I have an array of objects that I want to save as a file
I want to save a 2D array to a CSV file with row and
I have an array which contains 12 numbers and I want to save this
I have a byte array that I want to save it as a bitmap
I have an array of checkboxes on the page and I want to save
I have an array of integers and I want to save pairs of integers
I have an array with objects, I want to save each one of them
I want to save to disk an array of objects as plist file .
I want to save a multidimensional array to a file. A struct for example:

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.