i need help on my homework problem.

i have done the operations part (+, -, *, /, sqrt) but i am really having a **problem on making my calculator accurate up to 40 digits and to truncate all the non-significant zeroes on the output**. i don't know what data type to use since i know that the highest decimal place the program can give me is only up to 6 decimal places.

can anyone help me write the codes needed for this? i am really having a problem on it right now. thanks a lot!