truncating front

This is a discussion on truncating front within the C Programming forums, part of the General Programming Boards category; Hi if I have an integer for instance int x= -3 and I try to print it in hex printf("%X", ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    6

    truncating front

    Hi

    if I have an integer for instance
    int x= -3

    and I try to print it in hex
    printf("%X", x);

    It prints out FFFFD.

    Is there an easy function in the library that will cut off some of the front F's?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    printf( "%X", x &0xFF );
    Width specifiers don't work with %X so you'll need to mask it like that.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    hmmm interesting...

    ~ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concatenating in linked list
    By drater in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 11:10 PM
  2. front audio panel
    By crvenkapa in forum Tech Board
    Replies: 1
    Last Post: 12-09-2007, 12:00 PM
  3. Queue and Stack: Comparing help!!! (palindrome)
    By advocation in forum C++ Programming
    Replies: 8
    Last Post: 03-09-2005, 07:46 PM
  4. Removing from the front of a Vector
    By Zildjian in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2004, 10:49 AM
  5. Bringing an Application to the Front in XP
    By Davros in forum Windows Programming
    Replies: 5
    Last Post: 11-25-2003, 09:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21