Quantcast
Channel: Product Communities
Viewing all articles
Browse latest Browse all 105279

Forum Post: Re: Rounding '5'

$
0
0

Have you experimented with both the Format and RoundTo functions in gINT?

This issue comes up now and then, and always when the last digit is '5'.

 

Here are some examples:

Examples of RoundTo Function output

55.5 formats to: <<Format(55.5,0)>>

55.5 rounds to (1): <<RoundTo(55.5,1)>>

55.5 rounds to (1+): <<RoundTo(55.5,1,+)>>

55.5 rounds to (1-): <<RoundTo(55.5,1,-)>>

54.5 formats to: <<Format(54.5,0)>>

54.5 rounds to (1): <<RoundTo(54.5,1)>>

54.5 rounds to (1+): <<RoundTo(54.5,1,+)>>

54.5 rounds to (1-): <<RoundTo(54.5,1,-)>>

Using MOD Operator

Basic expression

<<IIf(_
  <<Calc(<<Int(55.5)>> MOD 2)>> = 0,_
  <<RoundTo(55.5,1,-)>>,_
  <<RoundTo(55.5,1,+)>>_
)>>

Expression rewritten:

55.5 rounds to:

<<Let(Value = 55.5)>>_
<<IIf(_
  <<Calc(<<Int(<<Get(Value)>>)>> MOD 2)>> = 0,_
  <<RoundTo(<<Get(Value)>>,1,-)>>,_
  <<RoundTo(<<Get(Value)>>,1,+)>>_
)>>

54.5 rounds to:

<<Let(Value = 54.5)>>_
<<IIf(_
  <<Calc(<<Int(<<Get(Value)>>)>> MOD 2)>> = 0,_
  <<RoundTo(<<Get(Value)>>,1,-)>>,_
  <<RoundTo(<<Get(Value)>>,1,+)>>_
)>>


Viewing all articles
Browse latest Browse all 105279

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>