Options

Check Datatype whether is Integer or decimal

fcjHHfcjHH Member Posts: 3
How it be examined can whether the result of a formula is a whole number or right-of-comma positions contained? :?

Comments

  • Options
    kinekine Member Posts: 12,562
    I do not understand what you want... please be more specific...

    result type is based on operators used and on used variables...


    1 / 2 = decimal
    1 div 2 = integer


    for example...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    fcjHHfcjHH Member Posts: 3
    i have this example:
    2500 / 500

    now i want to check, if the result is an integer or a decimal.
    if it's an integer, i have to do something different, if it's a decimal with 1 or more decimal-places i can do another step.

    i tried it: Variable XXX as variant an the code: ok := xxx.isinteger
    but if the result is 4, this does not recognize it as an integer.

    :?:
  • Options
    kinekine Member Posts: 12,562
    more ways:
      if XXX = ROUND(XXX,1) then
        Message('Is integer')
      else
        Message('Is Decimal');
    
      if (XXX / YYY) = (XXX div YYY) then
        Message('Is integer')
      else
        Message('Is Decimal');
    

    it depend on what you have...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    BeniHochBeniHoch Member Posts: 15
    An other way:

    if (x mod 1) <> 0 then
    there is an remainder

    expl.:
    x := 85.3;
    x mod 1 = 0.3
  • Options
    2tje2tje Member Posts: 80
    or try using the EVALUATE function

    IF EVALUATE(IntVar,Result) then
    integer
    ELSE
    decimal;
Sign In or Register to comment.