Jump to content
  • 0

Afronden in centen en splitsen op de comma


sjuul

Question

Posted

Hallo,

 

Ik probeer een calculatie te maken, welke uit mijn prijsveld (met vijf decimalen) de centjes achter de comma losmaakt, en afrond naar boven.

 

waarde in mijn prijsveld: 19,94587

gewenste uitkomst: ,95

 

Mijn hack so-far:

Let ( 
$prijs = GetAsText ( Prijs in ) ; 

Round ( Right ( $prijs ; Position ( $prijs ; "," ; 1 ; 1 ) ) ; 2 )
)

 

Wie leid mij op weg?

3 answers to this question

Recommended Posts

  • 0
Posted

Round zal enkel afronden en je wil eigenlijk altijd naar boven afronden.

Daarvoor hebben ze de Ceiling functie geintroduceerd.

 

Let
(
[
theValue = Prijs In // 19,94587
;
theValue = theValue - Floor(theValue) // 19,94587 - 19 = 0,94587
;
theValue = theValue * 100 // 94,587
;
theValue = Ceiling(theValue) // 95
;
theValue = theValue/100 // 0,95
]
;
theValue
)

 

 

Of iets korter uitgeschreven:

 

Let
(
[
theValue = Prijs In
]
;
Ceiling (( theValue - Floor(theValue) ) * 100) / 100
)

 

waarde in prijsveld: 19,94587

uitkomst: ,95

 

waarde in prijsveld: 19,941234

uitkomst: ,95

 

waarde in prijsveld: 19,94

uitkomst: ,94

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...