Thread: Adding uint_64 whit uint_32

  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    4

    Adding uint_64 whit uint_32

    How do I do this. I tried whit casting but the whole thing still evaluates to zero.

    uint_64 a;
    uint_32 b;

    int c = a +b;

    c will be zero right?

    How do I do this?

    Regards

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Both a and b are uninitialized, so whatever c happens to end up is undefined.


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

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    4
    Quote Originally Posted by quzah View Post
    Both a and b are uninitialized, so whatever c happens to end up is undefined.


    Quzah.
    Sorry for the bad example. But I have figured out the problem. A uint_64 have to be printed whit %llu instead of %d.

    Thanks

  4. #4
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    And uint_32 should be printed with %u.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    uint64_t uses PRIu64
    uint32_t uses PRIu32

    Those are macros in inttypes.h If your compiler doesn't define those, it would probably be best to define them in a compiler-specific ifdef.

    Assuming, of course, that you really mean uint32/64_t, and not uint32/64.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamic adding of Controls
    By WDT in forum C# Programming
    Replies: 5
    Last Post: 04-22-2009, 07:59 AM
  2. Adding nodes to a linked list
    By bluescreen in forum C Programming
    Replies: 4
    Last Post: 11-09-2006, 01:59 AM
  3. SVN Import Causes Crash
    By Tonto in forum Tech Board
    Replies: 6
    Last Post: 11-01-2006, 03:44 PM
  4. Java: Sorting and Adding a Row in Table
    By alphaoide in forum Tech Board
    Replies: 4
    Last Post: 08-12-2005, 08:22 PM
  5. Adding your own API calls.
    By 0x7f in forum Windows Programming
    Replies: 1
    Last Post: 04-08-2003, 06:00 PM