Thread: hton long long

  1. #1
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404

    hton long long

    I need some suggestions. What would be the best way to make an hton for data stored as a long long? Should I make a brand new function or use a type of manipulation of the already made hton's? I have been attempting to write my own function but I am having a tough time.

    Your thoughts?

    Well, I finally found something to do it? Is this some decent code?
    Code:
    unsigned long long htonll (unsigned long long hostlonglong)
    {
    	unsigned long long retval;
    	
    	retval = hostlonglong;
    
    	retval = ((unsigned long long) htonl(hostlonglong & 0xFFFFFFFF)) << 32;
    	retval |= htonl((hostlonglong & 0xFFFFFFFF00000000) >> 32);
    
       return(retval);
    }
    Last edited by carrotcake1029; 06-01-2008 at 07:16 PM.

  2. #2
    Registered User
    Join Date
    May 2008
    Posts
    12
    Looks good.

    I use one almost exactly like your code. Haven't encountered problems so far.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 09-30-2008, 02:12 AM
  2. Having Buffer Problems With Overlapped I/O --
    By Sargera in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 04:46 PM
  3. Problem in Converting Unsigned long to String
    By cprogrammer_18 in forum C Programming
    Replies: 8
    Last Post: 01-14-2006, 08:57 AM
  4. Merge and Heap..which is really faster
    By silicon in forum C++ Programming
    Replies: 2
    Last Post: 05-10-2005, 04:06 PM
  5. Insertion Sort Problem
    By silicon in forum C++ Programming
    Replies: 1
    Last Post: 05-08-2005, 12:30 PM