How do I print 64 bit unsigned integer in hex? (2024)

  • Forum
  • General Programming Boards
  • C Programming
  • How do I print 64 bit unsigned integer in hex?
  • Thread Tools
    • Show Printable Version
    • Email this Page…
    • Subscribe to this Thread…
  • Search Thread
  • Display
    • Switch to Hybrid Mode
    • Switch to Threaded Mode
  1. 02-10-2003#1

    electrolove

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (2)

    Registered User

    Join Date
    Feb 2003
    Posts
    63

    How do I print 64 bit unsigned integer in hex? (3) How do I print 64 bit unsigned integer in hex?

    I wonder how I use printf to print an unsigned 64 bit integer in hex? I want to print all positions, even if they are zero like this:

    0000000000000000

    or:

    00FFFFFFFFFFFFFF

    or:

    000C5AB7643DAA4F

    You cant´t teach an old dog new tricks.

  2. 02-10-2003#2

    Hammer

    • View Profile
    • View Forum Posts
    • Visit Homepage

    How do I print 64 bit unsigned integer in hex? (4)

    End Of Line

    Join Date
    Apr 2002
    Posts
    6,231
    printf() format modifiers maybe. This is the code for a regular int:
    >printf ("%010d\n", 9);
    The first 0 of 010 tells the compiler to print leading 0's.

    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. 02-10-2003#3

  4. 02-11-2003#4

    electrolove

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (8)

    Registered User

    Join Date
    Feb 2003
    Posts
    63

    How do I print 64 bit unsigned integer in hex? (9)

    Originally posted by penney
    printf("%016X\n",your_num);

    This does not work. When building I get a warning:

    unsigned int format, difference type arg (arg 2)

    And the resulting output is:

    00000000FFFFFFFF

    This is my code:

    UInt64 your_num = 0xffffffffffffffff;
    printf("%016X\n", your_num);

    What is wrong?

    You cant´t teach an old dog new tricks.

  5. 02-11-2003#5

    Monster

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (10)

    Me want cookie!

    Join Date
    Dec 2001
    Posts
    680
    Try:

    Code:

    printf("%016llX\n", your_num);
  6. 02-11-2003#6

    electrolove

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (12)

    Registered User

    Join Date
    Feb 2003
    Posts
    63

    How do I print 64 bit unsigned integer in hex? (13)

    Originally posted by Monster
    Try:

    Code:

    printf("%016llX\n", your_num);

    IT WORKS!!!

    Thanks a lot my friend. No build error and the output is exactly as it should. I own you one :-)

    What have this learned me? Well, even Monster's can be nice, heh...How do I print 64 bit unsigned integer in hex? (14) How do I print 64 bit unsigned integer in hex? (15) How do I print 64 bit unsigned integer in hex? (16)

    You cant´t teach an old dog new tricks.

  7. 02-11-2003#7

    Monster

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (17)

    Me want cookie!

    Join Date
    Dec 2001
    Posts
    680

    Originally posted by electrolove
    IT WORKS!!!

    Thanks a lot my friend. No build error and the output is exactly as it should. I own you one :-)

    What have this learned me? Well, even Monster's can be nice, heh...How do I print 64 bit unsigned integer in hex? (19) How do I print 64 bit unsigned integer in hex? (20) How do I print 64 bit unsigned integer in hex? (21)

    It's from cookie monster.... I love cookies How do I print 64 bit unsigned integer in hex? (22)

    b.t.w. I'm not sure if this is ANSI C

  8. 02-11-2003#8

    Sargnagel

    • View Profile
    • View Forum Posts

    How do I print 64 bit unsigned integer in hex? (23)

    Registered User

    Join Date
    Aug 2002
    Posts
    166

    Originally posted by Monster
    b.t.w. I'm not sure if this is ANSI C

    As far as I understand the ANSI C Standard, I would say "%016llX" is ANSI C conform.

    0 For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversions, leading zeros
    (following any indication of sign or base) are used to pad to the field width rather
    than performing space padding, except when converting an infinity or NaN. If the
    0 and - flags both appear, the 0 flag is ignored. For d, i, o, u, x, and X
    conversions, if a precision is specified, the 0 flag is ignored. For other
    conversions, the behavior is undefined.
    ...
    ll (ell-ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a
    long long int or unsigned long long int argument; or that a
    following n conversion specifier applies to a pointer to a long long int
    argument.
    ...
    o,u,x,X The unsigned int argument is converted to unsigned octal (o), unsigned
    decimal (u), or unsigned hexadecimal notation (x or X) in the style dddd; the
    letters abcdef are used for x conversion and the letters ABCDEF for X
    conversion. The precision specifies the minimum number of digits to appear;
    if the value being converted can be represented in fewer digits, it is expanded
    with leading zeros. The default precision is 1. The result of converting a
    zero value with a precision of zero is no characters.

Quick NavigationC ProgrammingTop

  • Site Areas
  • Settings
  • Private Messages
  • Subscriptions
  • Who's Online
  • Search Forums
  • Forums Home
  • Forums
  • General Programming Boards
    1. C++ Programming
    2. C Programming
    3. C# Programming
    4. Game Programming
    5. Networking/Device Communication
    6. FAQ Board
    7. Programming Book and Product Reviews
  • Platform Specific Boards
    1. Windows Programming
    2. Linux Programming
  • Cprogramming.com and AIHorizon.com's Artificial Intelligence Boards
    1. General AI Programming
  • Community Boards
    1. Article Discussions
    2. Tech Board
    3. General Discussions
    4. A Brief History of Cprogramming.com
    5. Contests Board
    6. Projects and Job Recruitment

«Previous Thread|Next Thread»

Popular pages

  • Exactly how to get started with C++ (or C) today
  • C Tutorial
  • C++ Tutorial
  • 5 ways you can learn to program faster
  • The 5 Most Common Problems New Programmers Face
  • How to set up a compiler
  • 8 Common programming Mistakes
  • What is C++11?
  • Creating a game, from start to finish

Recent additions How do I print 64 bit unsigned integer in hex? (25)

  • How to create a shared library on Linux with GCC - December 30, 2011
  • Enum classes and nullptr in C++11 - November 27, 2011
  • Learn about The Hash Table - November 20, 2011
  • Rvalue References and Move Semantics in C++11 - November 13, 2011
  • C and C++ for Java Programmers - November 5, 2011
  • A Gentle Introduction to C++ IO Streams - October 10, 2011

Similar Threads

  1. 32 bit or 64 bit allignment ?! gcc options??

    By mynickmynick in forum C Programming

    Replies: 3

    Last Post: 07-29-2008, 02:43 AM

  2. bit level permutation function

    By zxcv in forum C Programming

    Replies: 2

    Last Post: 07-27-2008, 01:26 PM

  3. Personal Program that is making me go wtf?

    By Submeg in forum C Programming

    Replies: 20

    Last Post: 06-27-2006, 12:13 AM

  4. Porting from 32 bit machine to 64 bit machine!

    By anoopks in forum C Programming

    Replies: 10

    Last Post: 02-25-2005, 08:02 PM

  5. What kind of programs should I start writing?

    By Macabre in forum C++ Programming

    Replies: 23

    Last Post: 04-12-2003, 08:13 PM

  • Contact Us
  • C and C++ Programming at Cprogramming.com
  • Web Hosting
  • Privacy Statement
  • Top

All times are GMT -6. The time now is 07:56 AM.

Powered by vBulletin® Version 4.2.5
Copyright © 2024 vBulletin Solutions Inc. All rights reserved.

Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - Copyright © 2024 DragonByte Technologies Ltd.

How do I print 64 bit unsigned integer in hex? (2024)

References

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 6141

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.