Test output value to see if it is INTEGER

1

I set the function below to check whether the output value is integer or real.

 funcao menu_8():inteiro
    var
    logaritmo :real
    inicio
    para contador de 0 ate 12 faca
          logaritmo <- ((log(i[contador])) / (log(2)))
          se ((logaritmo % 2 = 0) OU (logaritmo % 2 = 1)) entao
             escreva(" é Potencia de 2: ", i[contador])
          fimse
    fimpara
    escreval(" ")
    fimfuncao

If it is real, it should not display anything on the screen.

If it is integer, it should display a message " é potencia de 2 "

How to test if LOGARITHM is INTEGER?

    
asked by anonymous 17.06.2016 / 16:32

1 answer

1

Use the int function to truncate the value. If the original value is equal to the truncated value, it is integer.

SE logaritmo = int(logatimo) ENTAO
    
17.06.2016 / 19:15