We have a program:

var a, b: real; function dg0(a, b : real) : real; var dg : real; f, r : longint; begin r := 1; repeat a := a * b; f := trunc(a); dg := dg + f * r; until a - trunc(a) = 0; writeln(dg); dg0 := dg; end; begin readln(a, b); writeln(dg0(a, b)); writeln('Нажмите Enter для выхода из программы'); readln; end. 

It must convert the decimal part of the decimal number а to the number system with the base b (input of a number in the format 0.111). On the 12th line ( f := trunc(a); ) gives the error:

Pattern.pas (12): Runtime Error: The value was unacceptably small or unacceptably large for Int32.

Please explain what the error is

  • @ nikrom3000 please format the code humanly. To do this, there is a special button {} in the question editor - DreamChild

1 answer 1

They also wrote to you: The value was unacceptably small or unacceptably large for Int32.

You f longint is the same as Int32 . Most likely, the integer part of a larger than can fit in an Int32 (-2147483648..2147483647 or -2 ^ 31..2 ^ 31-1). In the line above, you multiply a by b .