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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:52:45+00:00 2026-05-25T17:52:45+00:00

I am formatting floats as follows: logFile.write(Loadcase: %6i %2i %4i %2.2f %2.2f %4f +

  • 0

I am formatting floats as follows:

logFile.write("Loadcase: %6i %2i %4i %2.2f %2.2f %4f + %4f -> " %(i, freq, amp, cutoff, end_time, penalty_inc, stab_inc))

and the result is like:

Loadcase:   5001  1   50 19.00 20.00 0.000000 + 0.000000 -> 0.495386 (ok)
Loadcase:   5002  2   50 9.50 10.00 0.000000 + 0.000000 -> 0.255045 (ok)
Loadcase:   5003  3   50 6.33 6.67 0.000000 + 0.000000 -> 0.151464 (ok)
Loadcase:   5005  5   50 3.80 4.00 0.000000 + 0.000000 -> 0.116979 (ok)
Loadcase:   5010 10   50 1.90 2.00 0.000000 + 0.000000 -> 0.081181 (ok)

I simply want the floats to be right aligned and some spaces inserted where necessary. I really basically want the table to be nicely aligned.
My guess of writing %2.2f seems to be ignored.

I cannot use numpy for technical reasons.

  • 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-25T17:52:45+00:00Added an answer on May 25, 2026 at 5:52 pm

    You’re misunderstanding what %2.2f means. It means “give the float 2 columns total, and display 2 positions after the radix point”. Perhaps you want %5.2f instead.

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

Sidebar

Related Questions

I like formatting my Java code in Eclipse. It keeps the code well indented
HI, Due to formatting issues, I'm converting floats to NSNumber in my iPhone app.
Possible Duplicate: String formatting options: pros and cons What's the difference between %.2f %
Possible Duplicate: JavaScript: formatting number with exactly two decimals Can some one please help
Possible Duplicate: USD Currency Formatting in Java All- I have a small problem in
Possible Duplicates: Formatting of if Statements Is there a best coding style for identations
im trying to formatting the date field 'created_at' from Twitter API response with Zend_Date.
I have some conditional formatting styles. I don't want to keep creating new rules
I want to do formatting using echo in shell scripting. Here is a small
Possible Duplicate: JavaScript: formatting number with exactly two decimals Now that I have got

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.