Visual G: What does the ':' character mean and how does it influence the results?

2

I'm learning to use visual g for this material here: link

In this particular code I have a very small question, which contains no answers in either material or google.

algoritmo "exemplo"
var x: real
y: inteiro
a: caractere
l: logico
inicio
x <- 2.5
y <- 6
a <- "teste"
l <- VERDADEIRO
escreval ("x", x:4:1, y+3:4) // Escreve: x 2.5    9
escreval (a, "ok")           // Escreve: testeok (e depois pula linha)
escreval (a, " ok")          // Escreve: teste ok (e depois pula linha)
escreval (a + " ok")         // Escreve: teste ok (e depois pula linha)
escreva (l)                  // Escreve: VERDADEIRO
fimalgoritmo
  

What I did not understand is how x (2.5): 4: 1 equals 2.5? Type, or   character ':' has no value and why the numbers 4 and 1?

I do not understand what this ':' character means and how it influences or not in the results.

    
asked by anonymous 28.06.2017 / 18:49

1 answer

0

From the documentation, the is following the Pascal model of writing. Anything, check Pascal documentation

As for the code: x:4:1 means four characters at the most at output, one being after the decimal; if the number does not fill in the four characters, put blanks. In the linked Freepascal documentation, the output would be 2.5 , with a space to the left of the printed number.

To see the effect, try to print 5.3:7:2 , it should print 5.30 . Three spaces before the number, two houses for decimals. Another interesting test is to print 5.29:3:1 , where the output (if rounded) is 5.3 ; three characters, a single decimal place.

    
28.06.2017 / 19:00