6 kyu

Big to Little Endian

131 of 141maerch

Description:

Your operating system screwed some things up. It has received some unsigned 32 bit integer from the Internet, but nobody told your OS about the "network byte order" and his "host byte order".

Your job is to write a function ntoh which takes a 32 bit unsigned integer in the Big Endian byte order and returns the correct 32 bit unsigned integer in the Little Endian order.

To refresh your knowledge about byte order. One byte are 8 bits, so a 32 bit unsigned integer consists of 4 bytes which are ordered the wrong way.

If an integer longer than 32 bit is given the function has to raise a nasty exception.

Example:

* 42949695 => 1063030530

42949695 as a 32 bit integer is

00000010 10001111 01011100 00111111 which translates to

00111111 01011100 10001111 00000010 which is 1063030530.

Algorithms

Stats:

CreatedMay 7, 2014
PublishedMay 7, 2014
Warriors Trained546
Total Skips361
Total Code Submissions741
Total Times Completed141
Ruby Completions131
COBOL Completions3
Total Stars10
% of votes with a positive feedback rating91% of 58
Total "Very Satisfied" Votes49
Total "Somewhat Satisfied" Votes7
Total "Not Satisfied" Votes2
Total Rank Assessments21
Average Assessed Rank
5 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • maerch Avatar
  • jhoffner Avatar
  • rowcased Avatar
  • akar-0 Avatar
  • dfhwze Avatar
Ad