OVH Cloud OVH Cloud

Round pas rond!

3 réponses
Avatar
Thierry
Bonjour,
Pourquoi round(1.5)=3D2 et round(2.5)=3D2 aussi?
J'aimerais comprendre avant de cr=E9er ma propre fonction=20
d'arrondi...
Thierry

3 réponses

Avatar
Thierry
Merci, effectivement ca marche.
Mais pourquoi round() ne marche pas?
Thierry.

-----Message d'origine-----
Bonjour,

Tu peux essayer la fonction Format :
Format(1.3, "0") = 2
Format(1.5, "0") = 2
Format(2.5, "0") = 3
Format(2.7, "0") = 3

ok ?

A+.
James RAVAILLE.


Bonjour,
Pourquoi round(1.5)=2 et round(2.5)=2 aussi?
J'aimerais comprendre avant de créer ma propre
fonction


d'arrondi...
Thierry

.





Avatar
Arnaud [lwa]
Bonjour Thierry,

si Round(Ccur(2.5)) retourne 3,
alors c'est que ton 2.5 initial est un réel donc virgule flottante.

converti en monétaire, peut-être que....
(pas vérifié)

a+
--
Arnaud
-----------------------------------
http://users.skynet.be/mpfa/
-----------------------------------



Dans sa missive, Thierry a atermoyé :
| Merci, effectivement ca marche.
| Mais pourquoi round() ne marche pas?
| Thierry.
|
|| -----Message d'origine-----
|| Bonjour,
||
|| Tu peux essayer la fonction Format :
|| Format(1.3, "0") = 2
|| Format(1.5, "0") = 2
|| Format(2.5, "0") = 3
|| Format(2.7, "0") = 3
||
|| ok ?
||
|| A+.
|| James RAVAILLE.
||
||
||| Bonjour,
||| Pourquoi round(1.5)=2 et round(2.5)=2 aussi?
||| J'aimerais comprendre avant de créer ma propre fonction
||| d'arrondi...
||| Thierry
|||
|| .
Avatar
Michel Walsh
Salut,


C'est plutôt l'arrondi dit du "banquier". Si on arrondissait le 0.5
toujours vers l'unité suivante, la banque y perdrait, à la longue. Donc, une
fois sur deux, on arrondi vers le haut (si la partie entière est impaire) et
l'autre fois (si la partie entière est paire), vers le bas... et le banquier
est content.


? Round(CCur(2.5))
2


(Access 2003).


Espérant être utile,
Vanderghast,Access MVP


"Arnaud [lwa]" <http://memoaccess.free.fr/> wrote in message
news:O1dz2i$
Bonjour Thierry,

si Round(Ccur(2.5)) retourne 3,
alors c'est que ton 2.5 initial est un réel donc virgule flottante.

converti en monétaire, peut-être que....
(pas vérifié)

a+
--
Arnaud
-----------------------------------
http://users.skynet.be/mpfa/
-----------------------------------



Dans sa missive, Thierry a atermoyé
:

| Merci, effectivement ca marche.
| Mais pourquoi round() ne marche pas?
| Thierry.
|
|| -----Message d'origine-----
|| Bonjour,
||
|| Tu peux essayer la fonction Format :
|| Format(1.3, "0") = 2
|| Format(1.5, "0") = 2
|| Format(2.5, "0") = 3
|| Format(2.7, "0") = 3
||
|| ok ?
||
|| A+.
|| James RAVAILLE.
||
||
||| Bonjour,
||| Pourquoi round(1.5)=2 et round(2.5)=2 aussi?
||| J'aimerais comprendre avant de créer ma propre fonction
||| d'arrondi...
||| Thierry
|||
|| .