Telfout

Gestart doorRobiin26 reacties3.204 weergaven

27 berichten · pagina 2 van 2

Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ceil"]ceil[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]


dat fixt het soms maar ook niet altijd dus emo
Waarom werk je eigenlijk met floats?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Alemaalte schreef:
Eerdere citaten tonen
Lennard schreef:
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ceil"]ceil[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]


dat fixt het soms maar ook niet altijd dus emo
Waarom werk je eigenlijk met floats?

Wat anders, alle punten als centen opslaan zegmaar?
Dus 1,60 punt wordt 160?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Caner schreef:
Eerdere citaten tonen
Dylanh schreef:
Offtopic:
Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.

t wordt toch afgerond op twee decimalen crycrycrycrycrycrycrycry
Ja maar als je het niet afrond?
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Caner schreef:
Eerdere citaten tonen
Dylanh schreef:
Offtopic:
Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.

t wordt toch afgerond op twee decimalen crycrycrycrycrycrycrycry
Ja maar als je het niet afrond?
Maar volgens mij is t een beetje raar als je 4.59999999999999964473 punten krijgt, denk je niet?
0,001e punt bestaat niet ...
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Thom schreef:
Eerdere citaten tonen
Dylanh schreef:
Eerdere citaten tonen
Caner schreef:
Eerdere citaten tonen
Dylanh schreef:
Offtopic:
Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.

t wordt toch afgerond op twee decimalen crycrycrycrycrycrycrycry
Ja maar als je het niet afrond?
Maar volgens mij is t een beetje raar als je 4.59999999999999964473 punten krijgt, denk je niet?
0,001e punt bestaat niet ...
Ik stel de vraag anders:

Hoe kan 4.60000000000000000000 nou 4.59999999999999964473 zijn? En dan bedoel ik dus niks met afronden of met punten.
0
Robiin

Lid · Topicstarter

Berichten
3.334
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Thom schreef:
Eerdere citaten tonen
Dylanh schreef:
Eerdere citaten tonen
Caner schreef:
Eerdere citaten tonen
Dylanh schreef:
Offtopic:
Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.

t wordt toch afgerond op twee decimalen crycrycrycrycrycrycrycry
Ja maar als je het niet afrond?
Maar volgens mij is t een beetje raar als je 4.59999999999999964473 punten krijgt, denk je niet?
0,001e punt bestaat niet ...
Ik stel de vraag anders:

Hoe kan 4.60000000000000000000 nou 4.59999999999999964473 zijn? En dan bedoel ik dus niks met afronden of met punten.
Inderdaad, dat geef ik toch niet op als ik Dylanh punten stuur?
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Thom schreef:
Eerdere citaten tonen
Dylanh schreef:
Eerdere citaten tonen
Caner schreef:
Eerdere citaten tonen
Dylanh schreef:
Offtopic:
Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.

t wordt toch afgerond op twee decimalen crycrycrycrycrycrycrycry
Ja maar als je het niet afrond?
Maar volgens mij is t een beetje raar als je 4.59999999999999964473 punten krijgt, denk je niet?
0,001e punt bestaat niet ...
Ik stel de vraag anders:

Hoe kan 4.60000000000000000000 nou 4.59999999999999964473 zijn? En dan bedoel ik dus niks met afronden of met punten.
Maar 4.59999999999999964473 is ook niet gelijk aan 4.6. En 4.6 hoeft ook niet 4.59999999999999964473 te zijn.
Het is ook niet gelijk aan elkaar, net als dat 4.6 niet 4.60000000000000000000 hoeft te zijn.

Maar wat is nou precies je punt?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Lennard schreef:
je verwacht nu 4.60000000000000000000 als output, maar je krijgt 4.59999999999999964473. Als je dat vervolgens met floor() op 2 decimalen afrondt, krijg je 4.59 ipv de verwachte 4.60. Met round() krijg je wel 4.60, dus moet zo beter zijn. smile
Ik wou dat dus weten waarom dat. Dus gewoon 4.59999999999999964893 kunnen zijn?
0
Berichten
21.633
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Maak er vooral een probleem van...
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Kijk dit eens. Dan snap je hoe dit soort rounding errors voorkomen smile
0
Berichten
5.957
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Eerdere citaten tonen
Alemaalte schreef:
Eerdere citaten tonen
Lennard schreef:
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ceil"]ceil[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]


dat fixt het soms maar ook niet altijd dus emo
Waarom werk je eigenlijk met floats?
Wat anders, alle punten als centen opslaan zegmaar?
Dus 1,60 punt wordt 160?

Ja dat lijkt mij beter niet?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Alemaalte schreef:
Eerdere citaten tonen
Lennard schreef:
Eerdere citaten tonen
Alemaalte schreef:
Eerdere citaten tonen
Lennard schreef:
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/floor"]floor[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    
    [COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/ceil"]ceil[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];
    
}[/COLOR]


dat fixt het soms maar ook niet altijd dus emo
Waarom werk je eigenlijk met floats?
Wat anders, alle punten als centen opslaan zegmaar?
Dus 1,60 punt wordt 160?
Ja dat lijkt mij beter niet?

Zou kunnen inderdaad, al werkt het verder prima zo. smile
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren