Hallo,
ich bin bei JFD und da sind nur lots in 0,05 Schritten möglich also z.B. so
0,40
0,45
0,50
0,55
0,60
0,65
usw...
bis jetzt habe ich das umgegangen in dem ich bis auf eine stelle hinter dem Komma gerundet habe
PHP-Code:
lot=NormalizeDouble(lot,1);
da kriege ich z.B. so was raus
0,4
0,5
0,6
die Schritte sind ziemlich grob, und habe mir folgendes zum "Aufrunden" gebastelt. Ab x,x3 bis x,x7 wird auf x,x5 gerundet usw.
PHP-Code:
lot=NormalizeDouble(lot,2);
double rest=lot % 0.05;
if (rest == 0.01) lot=lot-0.01;
if (rest == 0.02) lot=lot-0.02;
if (rest == 0.03) lot=lot+0.02;
if (rest == 0.04) lot=lot+0.01;
if (rest == 0.06) lot=lot-0.01;
if (rest == 0.07) lot=lot-0.02;
if (rest == 0.08) lot=lot+0.02;
if (rest == 0.09) lot=lot+0.01;
doch die Freude war kurz, da das Problem dabei ist, dass "%" Operator nur mit
int Zahlen umgehen kann.
Hat jemand eine Idee wie man das lösen könnte ?
Gibts ein Befehl dass die letzte Stelle einer double Zahl auslesen kann ?
danke