Telfout

Robiin

New member
Hoi,

Er zit een telfout in het systeem;

De PM:

Quote:
Hoi Robiin,

Je hebt op 23 januari om 21:06 uur 4,6 punten ontvangen van **.
Het bericht wat ** heeft opgegeven, is:
**

Met vriendelijke groet,

one2xs team


De log:

Quote:
23 jan 2014, 21:06 Punten overschrijving van ** 4,59


Nu heb ik 0.01 te kort
cry.gif
(
emo.gif
)
 

Lennard

Active member
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...


Codeblok:



1
2
3
4
5
6
7
8
9
10
11
12
13

[COLOR= #0000BB]<?php[/COLOR]
if[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] floor[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];

}[/COLOR]
else
[COLOR= #007700]{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] ceil[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.gif
 

Lennard

Active member
Sjoerd (link):
Waarom die else? Of worden er ook negatieve bedragen gestuurd?
confused.gif

als ik jou 1 punt stuur dan gaat ie er bij mij af
yummie.gif
 

Sjoerd

Active member
Lennard (link):

Sjoerd (link):
Waarom die else? Of worden er ook negatieve bedragen gestuurd?
confused.gif

als ik jou 1 punt stuur dan gaat ie er bij mij af
yummie.gif




Och..
emo.gif

Maar ligt het probleem hier dan niet voor? Ik zie bij de opmerking staan dat er 4.6 gestuurd is. Bij de een is er 4,59 af en bij de ander is er 4,59 bij gekomen.
Waarom check je niet ergens of die 4.6 gelijk is aan die 4,59?
 

Dylan

<script>
Las net op php.net/ceil dat dat komen door floats en int ofzo, dus misschien:

$amount = (float) floor($amount * 100) / 100;

$amount = (float) ceil($amount * 100) / 100;


Float was toch een int maar dan met een decimaal(en)?
 

Lennard

Active member
https://bugs.php.net/bug.php?id=64674

Heb nu round() ipv ceil() en floor(), even kijken of het zo beter gaat.
smile.gif

Daar staat ook een uitleg waarom het fout gaat.

Dit gebeurt er als je 4,6 punten overmaakt:

Codeblok:



1
2
3
4

[COLOR= #0000BB]<?php
$amount[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]4.6[/COLOR][COLOR= #007700];[/COLOR]

echo number_format[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]20[/COLOR][COLOR= #007700]);[/COLOR]






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.gif



toevoeging op 24 januari 2014, 22:06:12:

Dylanh (link):
Float was toch een int maar dan met een decimaal(en)?


Klopt!
 

Antonn

New member
En nu steeds 0,010000000001 versturen en dan de andere 0,02 ontvangen, devhele dag door
emo.gif


Verdien je meer dan als je dogecoins gaat mijnen
emo.gif
 

Lennard

Active member
ja probeer het
biggrin.gif
net als mensen die de paypalbetaalpagina hier op one2xs denken te hacken zodat ze met € 0,10 punten kunnen kopen (het minimumbedrag is normaal € 0,50) en dan huilen dat er punten worden afgeschreven i.p.v. bijgeschreven.
emo.gif
 

Caner

Held
Dylanh (link):
Offtopic:

Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.


t wordt toch afgerond op twee decimalen
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
 

Bugged

New member
Caner (link):

Dylanh (link):
Offtopic:

Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.


t wordt toch afgerond op twee decimalen
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif




In mijn ogen is 4.59999999999999964473 afgerond toch 4.60? Het 3e getal is > 5 dus dan is het toch 4.60?
 

Robiin

New member
Bugged (link):

Caner (link):

Dylanh (link):
Offtopic:

Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.


t wordt toch afgerond op twee decimalen
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif




In mijn ogen is 4.59999999999999964473 afgerond toch 4.60? Het 3e getal is > 5 dus dan is het toch 4.60?



Jah, maar zal wel afgehakt worden oid.
 

Alemaalte

New member
Lennard (link):
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...


Codeblok:



1
2
3
4
5
6
7
8
9
10
11
12
13


[COLOR= #0000BB]<?php[/COLOR]
if[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] floor[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];

}[/COLOR]
else
[COLOR= #007700]{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] ceil[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.gif




Waarom werk je eigenlijk met floats?
 

Lennard

Active member
Alemaalte (link):

Lennard (link):
Ja, PHP bug ofzo, komt eens in de zoveel tijd voor en géén idee waarom...


Codeblok:



1
2
3
4
5
6
7
8
9
10
11
12
13


[COLOR= #0000BB]<?php[/COLOR]
if[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]>[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] floor[COLOR= #007700]([/COLOR][COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]*[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700])[/COLOR] / [COLOR= #0000BB]100[/COLOR][COLOR= #007700];

}[/COLOR]
else
[COLOR= #007700]{[/COLOR]

[COLOR= #0000BB]$amount[/COLOR] [COLOR= #007700]=[/COLOR] ceil[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.gif




Waarom werk je eigenlijk met floats?

Wat anders, alle punten als centen opslaan zegmaar?
Dus 1,60 punt wordt 160?
 

Dylan

<script>
Caner (link):

Dylanh (link):
Offtopic:

Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.


t wordt toch afgerond op twee decimalen
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif




Ja maar als je het niet afrond?
 

Thom

Thom
Dylanh (link):

Caner (link):

Dylanh (link):
Offtopic:

Ik begrijp nog steeds niet dat 4.6 gelijk is aan 4.59999999999999964473.


t wordt toch afgerond op twee decimalen
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif
cry.gif




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 ...
 
Bovenaan