I was asked the following question and I didn’t know how to answer it. I was wondering if anybody could help:
Using C#, and not using any Math functions (Round() and Truncate() aren’t allowed) take the following double 3.009784654 and round it to 4 decimal places.
This was for an interview, not for a class project or homework. The interviewer seemed to be trying to get me to use mod, but I still couldn’t think of how to do it.
Thanks!
To truncate (since rounding rules were not specified): multiply by 1e4, cast to int, divide by 1e4.