Get a unique, high-quality and non-plagiarized paper from us today at the most affordable price
Email us : premieredtutorials@gmail.com

Coding

Please answer the next 4 questions following the instructions of them -the way that the question ask for precisely- the first three parts in java – simple java. and the part 4 by c language.
—————————————————————–
Part 1. Using the bitwise operators (&, |, ^, ~, – (2’s complement/unary negation), <<, >>, and >>>) discussed in class, write a function in Java that swaps (returns) the byte order of an integer from one endian-ness to the other. A template for the Java function follows:
static int swap ( int i ) {
.
.
.
}

Part 2. Using only the the arithmetic operators (+, -, *, /, %, and – (2’s complement/unary negation)), implement a Java function that also swaps the byte order of an integer (ifs are OK too). Note that it is actually much more difficult to do this using only the arithmetic operators! Hint: First implement it correctly for positive i, and only then begin working on the version that also handles negative i. A template for this Java function follows:
static int swap2 ( int i ) {
.
.
.
}

Part 3. Using a timing methods such as the Java code below, time your swap and swap2 methods by repeatedly calling them many, many times. Report your results in the number of seconds required for one function call.
final int N = 1000000;

long start = System.nanoTime();
for (int i=0; i<N; i++) {
int x = swap( 0x01020304 );
}
long elapsed = System.nanoTime() – start;
System.out.println( “elapsed time = ” + (elapsed/1E9/N) );

Furthermore, since C and C++ have pointer variables, another approach is possible. But please use only the bitwise ones in part 1, and only the arithmetic ones in part 2. Do not use any built in functions that may exist, and certainly do not manipulate them as strings!

You are required to test your program using the following input: 0x01020304, 0x010203ff, 0xff020304, 0xfe020304, and 0x80aacc84. Email your code and output to me and our excellent TA.

Part 4. Write a C program with a function that changes the byte order of an integer by treating it as an array of characters. The function should be defined as the following:
void swap ( char* data ) {

}
It should be called like the following: int k = 0x0a0b0c0d;
swap( (char*) &k );
After swap, the byte order of k should become 0x0d0c0b0a.

 

For a custom paper on the above topic, place your order now!

 

What We Offer:

 

  • On-time delivery guarantee

 

  • PhD-level writers

 

  • Automatic plagiarism check

 

  • 100% money-back guarantee

 

  • 100% Privacy and Confidentiality

 

  • High Quality custom-written paper

How to Place an Order 

Send the assignment details such as the instructions, due date/deadline, number of pages and college level to the customer support agent online on live chat,  fill in the assignment details at place an order or send the information to our email address premieredtutorials@gmail.com and a customer support agent will respond to you immediately. 

Once you place your order, we choose for you the best and competent writer for your assignment based on each writer’s competence in handling a subject. 

When the homework is completed, we have a quality assurance team that proofreads the assignment to ensure it meets the required rubric instructions from your professor.

After thorough review of your assignment, we send the paper to the client. In case you need any changes at this point, you can let us know so that we can handle it for you at no extra charge. 

Homework Help Website

Why we should write your Paper 

  1. Money Return guarantee
  2. 0% Plagiarism Rate
  3. Guaranteed Privacy
  4. Written from scratch by highly qualified writers 
  5. Communication at Any Time (24/7)
  6. Flexible Pricing and Great Discount Programs
  7. Timely Deliveries
  8. Free Amendments
Looking for a similar assignment and in urgent need for help? Place your order and have excellent work written by our team of professionals to ensure you acquire the best grades.

  We are here to assist you.

 

Statistics about Us

130 New Projects
235 Projects in Progress
315 Inquiries
420 Repeat clients

© 2021 Premiered Tutorials
All rights reserved. We provide online custom written papers, such as term papers, research papers, thesis papers, essays, dissertations and other custom writing services.

All papers inclusive of research material are strictly intended to be used for research and study purposes only. Premiered Tutorials does not support or condone plagiarism in any form. These custom papers should be used with proper reference.

Place an Order
error: Content is protected !!