What I don't know is, first of all, how to go through a number digit by digit, and checking if each number is a zero. Then the power the new number would be raised to would be the number of zeroes in front of the significant digits. The program would then only keep the first 15 digits after the decimal, so the number would be truncated to. If I wanted ten significant figures, I would do five + ten = 15. Then the next step could truncate the number to that counter plus however many significant digits I want. I was thinking of maybe looping through the number, digit by digit? The program could add 1 to a counter when the number is equal to zero, and then break out of the loop once it hits anything other than zero. That, and having a number go out to 50 figures is very useless. I just need a way to round it off to around ten sig figs before moving on to the next calculation in order to prevent overflow errors. I only care about the first 10 or so significant digits. The numbers can get as small as to the 1E-50. First of all, all of the numbers I will be rounding will always be less than 1. I need a way to round specific numbers to a certain amount of significant digits. It's resulting from things like dividing a 50 digit number by another 50 digit number. So I have a bunch of calculations in a program I'm making, and the numbers are getting so long that I'm getting overflow errors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |