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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:34:42+00:00 2026-05-11T08:34:42+00:00

There was a bit of a surprise with some code today. I was compiling

  • 0

There was a bit of a surprise with some code today. I was compiling it on AIX, with the warning level set to anal to see what rogue issues might be lurking. Something new crawled out of the code.

 1540-2837 (W) '0' flag is disregarded when combined with                 precision and 'i' printf format. 

After looking at the offending line, I put together a little program to reproduce it. Testing it on several platforms showed that it is not AIX specific.

The first printf below mimics what was found in the program.

#include <stdio.h>     int main(void) {     int x = 3;      printf('Format 0.3i <%0.3i>\n', x);  // prints 003, and AIX does a warning     printf('Format  .3i <%.3i>\n', x);   // prints 003, with no warning     printf('Format   3i <%3i>\n', x);    // prints   3, with no warning.      return 0; } 

Normally, if leading zeros were needed, a format of ’03i’ would do the job nicely.

What does ‘%.3i’ really mean here?

Why does it have the behavior that it does?

  • 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. 2026-05-11T08:34:42+00:00Added an answer on May 11, 2026 at 8:34 am

    .X, where x is a number means ‘print at least X’ digits, so %.3i means print at least 3 digits. If the number is less than 100, it is left padded with zeros.

    From a doc on printf

    ‘For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0.’

    There is another concept, ‘width’ (e.g. ‘%3i’) which causes a certain number of characters to be output (not necessarily digits, and the 0 specified is used to say that those characters should be 0s, as in ‘003’ and not spaces, as in ‘ 3’)

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

Sidebar

Related Questions

is there a possible bit of code (php, java, css, html) that will force
I'm looking at http://hseeberger.wordpress.com/2010/11/25/introduction-to-category-theory-in-scala/ and there's a bit of code that I can't understand
There's this very simple bit a code <asp:TextBox ID=txbVipNumber runat=server /> <asp:TextBoxWatermarkExtender ID=tbweVipNumber runat=server
I came across a case-switch piece of code today and was a bit surprised
I have some old code written in C for 16-bit using Borland C++ that
There seems to be quite a bit of folklore knowledge floating about in restricted
With 32 bit floats I think there is something like 2^31 - 1 representable
Bit of an odd question but is there a way of seeing what objects
While there are multiple ways to reverse bit order in a byte, I'm curious
Is there a way to obtain a particular bit in a hexadecimal number to

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.