Question

Using R programming, write a program to compute the Machine epsilon in single precision(32 bits) and...

Using R programming, write a program to compute the Machine epsilon in single precision(32 bits) and double precision(64 bits). Follow programming guidelines.

Homework Answers

Answer #1

#include <stdio.h>

#define N 100000

#define TYPE float

int main(void)

{      TYPE max = 1.0, min = 0.0, test;

int i;

for (i = 0; i < N; i++)

{ TYPE one_plus_test;

test = (max + min) / ((TYPE)2.0);

one_plus_test = ((TYPE)1.0) + test;

if (one_plus_test == ((TYPE)1.0))

{

min = test;

}    else

{

max = test;   

}    

}

printf("The epsilon machine is %.50lf\n", max);

return 0;

}

typedef union {

long long i64;

double d64;

} dbl_64;

double machine_eps (double value)

{

dbl_64 s;

s.d64 = value; s.i64++;

return s.d64 - value;

}

 
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For each of the following, assume that we are using a 32-bit system with single-precision (32-bit)...
For each of the following, assume that we are using a 32-bit system with single-precision (32-bit) floating point numbers (floats) in IEEE format, double-precision (64-bit) doubles in IEEE format, and 32-bit integers. Which of the following evaluate to true for all argument values? (Circle each that is always true). char c = .. int x = .. short y = .. float f = .. double d = .. c == (char)(float) c y == (short)(int) y f == (float)(double)...
Write an assembly language program that reverses all the bits of a 32-bit number. (Without using...
Write an assembly language program that reverses all the bits of a 32-bit number. (Without using RBIT instruction) Write an assembly language program that checks whether an unsigned number is perfect square or not.
Matlab uses IEEE double precision numbers: 64-bit floating point representation 1 bit : sign 11 bits:...
Matlab uses IEEE double precision numbers: 64-bit floating point representation 1 bit : sign 11 bits: exponent 52 bits: mantissa. Calculate largest number (less than inf) that can be stored accurately Calculate smallest number (x>0) that can be stored accurately Calculate the machine epsilon Show all work step by step and repeat for 10 bit floating point (bit sign, 4 bits exponent and 5 bits mantissa)
Matlab uses IEEE double precision numbers: 64-bit floating point representation 1 bit : sign 11 bits:...
Matlab uses IEEE double precision numbers: 64-bit floating point representation 1 bit : sign 11 bits: exponent 52 bits: mantissa. Calculate largest number that can be stored accurately Calculate smallest number (x>0) that can be stored accurately Calculate the machine epsilon Show all work step by step and explain calculations Now calculate the largest number and smallest number for a 10 bit floating point (1 bit for the sign, 4 bits exponent and 5 bits mantissa)
In C programming, Thank you Write a program to compute the area of a circle. You...
In C programming, Thank you Write a program to compute the area of a circle. You have to write a complete ā€œCā€ program that compiles and runs in Codeblocks. Program requirements: 1. Declare the variables needed: radius (r) and area (yourLastName). 2. Calculate and print the area of each circle. 3. The program MUST prompt the user for a new radius (r) over and over until the user types -1. 5. Use the type double for all decimal numbers. 6....
Using R Programming language write a program to Check Prime Number (entered by the user) using...
Using R Programming language write a program to Check Prime Number (entered by the user) using control statements. Note: a prime number is an integer number greater than 1 whose only factors are 1 and itself. For example: 2, 3, 5, 7, 11, 13, 17.19 etc. USING R PROGRAMMING
write a single instruction using 16 bit operands that clears the high 8 bits of AX...
write a single instruction using 16 bit operands that clears the high 8 bits of AX and does not change the low 8 bits
11. Write a program to compute the sum of the series 12 + 22 + 32....
11. Write a program to compute the sum of the series 12 + 22 + 32. . . ., such that the sum is doesnot exceed 1000. The program should display how many terms are used in the sum. {3 marks} matlab only 1 to power of 2 , 2 to the power of 2 , 3 to the power of 3 , not 12 + 22 + 32
Using the IEEE single-precision floating point representation, find the decimal number represented by the following 32-bit...
Using the IEEE single-precision floating point representation, find the decimal number represented by the following 32-bit numbers, each expressed as an 8-digit hex number. Express your answer using decimal scientific notation. (a) (C6500000)16 (b) (31200000)16
Listing 1 shows ABCD.cpp program to compute diameter, circumference and area for a circle with r,...
Listing 1 shows ABCD.cpp program to compute diameter, circumference and area for a circle with r, radius without user-defined function. Listing 2 shows the expected output of ABCD.cpp on the screen after creating user-defined functions for 3 circles of radius. Write a complete code to compute an output of 3 circles with r, radius as shown in Listing 2. Your answer should have four (4) functions as stated below as function declaration. double displayRadius(double); double displayDiameter(double); double displayCircumference(double); double displayArea(double);
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT