How Normalize() is calculated?
Try something like:
// get a one with digit zeros behind/ 10, 100, 1000
double f= 1;
for (int i= 0; i<digits; i++) {
f*= 10;
}
// round it up
double result= (int)(roundwhat*p + 0.5);
result/= p;
Markus
// get a one with digit zeros behind/ 10, 100, 1000
double f= 1;
for (int i= 0; i<digits; i++) {
f*= 10;
}
// round it up
double result= (int)(roundwhat*p + 0.5);
result/= p;
Markus
Shimodax, your calculation is incorrect. The result of your calculation and result of the original Normalize() is different.
But thank you anyway.
But thank you anyway.
Hi!
I just hacked it up here in the message window (just saw that "p" shoudl be "f"). But I think it will be something like that.
However, I just tried this and it gave the same result as NormalizeDouble(d, 4); => Result 1.2346
I just hacked it up here in the message window (just saw that "p" shoudl be "f"). But I think it will be something like that.
However, I just tried this and it gave the same result as NormalizeDouble(d, 4); => Result 1.2346
double roundwhat= 1.234567;
int digits= 4;
// get a one with digit zeros behind/ 10, 100, 1000
double f= 1;
for (int i= 0; i<digits; i++) {
f*= 10;
}
// round it up
double result= (int)(roundwhat*f + 0.5);
result/= f;
Oh, nevermind ... it was worth a try :-)
Markus
Markus
I need to know this urgently too. How to rewrite NormalizeDouble() in C/C++? Maybe this function is somehow flawed that's why it rounds numbers randomly?
How to rewrite the Normalize() function in C ?
Thanks in advance