- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- Languages and Scripting
- >
- printf bug with '0' flag under HP-UX 11.11
-
-
Forums
- Products
- Servers and Operating Systems
- Storage
- Networking
- Software
- Services
- Company
- Events
- Webinars
- Partner Solutions and Certifications
- Local Language
- China - 简体中文
- Japan - 日本語
- Korea - 한국어
- Taiwan - 繁體中文
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Latin America
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Forums
-
Blogs
-
Information
-
English
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-01-2020 09:10 AM
04-01-2020 09:10 AM
With printf under HP-UX 11.11 (hppa2.0w-hp-hpux11.11), the '0' flag is ignored when a negative precision argument is given, such as in
printf ("%05.*d\n", -1, 1);The expected output is "00001", but under HP-UX, one does not get the 0's.
ISO C99 says in 7.19.6.1 ("The fprintf function"):
#5 A negative precision argument is taken as if the precision were omitted.
#6 For d, i, o, u, x, and X conversions, if a precision is specified, the 0 flag is ignored.
Note the difference between "precision" and "precision argument".
The reason of the above rule is that if a precision is specified, the number of leading 0's is already implied by the precision. Without this rule, there would be an inconsistency.
HP-UX seems to assume that a negative precision argument is like a given precision, thus ignores the '0' flag. But there are no reasons to ignore the '0' flag in this case: there is no explicit precision that fixes the number of leading 0's. Glibc (Linux), FreeBSD, NetBSD, OpenBSD and AIX all behave correctly.
This yields an error in the MPFR test suite.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
04-01-2020 03:37 PM
04-01-2020 03:37 PM
Solution> With printf under HP-UX 11.11 (hppa2.0w-hp-hpux11.11), [...]
Yup. But you might have missed the window where anyone cares:
https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf
> [...] all behave correctly.
its $ cc /version
HP C V7.3-020 on OpenVMS IA64 V8.4
its $ cc of
its $ link of
its $ run of
00001
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP

