Sign in Join
Wiki copytemporary

Div/es

Deutsch · English · Español · Français · Suomi · Русский

Div es la división en la cual la parte fraccionaria (resto) se descarta. La expresión (a div b) devuelve la parte entera del resultado de la división entre dos números eneteros. Esto contrasta con la expresión (a / b) que devuelve un Real como resultado. Cuando se utiliza div tanto el dividendo como el divisor deben ser de algún tipo de enetero (loginteger, word, shortint, etc.). El uso de un operando real con div resultará en un error de compilación: "Error: Operator is not overloaded:". Para obtener un resultado entero con un operando real, se puede utilizar trunc o Round con el operador /.

Ejemplo:

pascal
var
  i : ShortInt = 16;
  j : ShortInt = 3;
  q : QWord = 1000;
  r : QWord = 300;

begin
  WriteLn(i div j); // 5
  WriteLn(i / j); // 5.3333333333333330E+000
  WriteLn(q div r); // 3
  Writeln(q / r) // 3.3333333333333335E+000
end.

Ver también


From the Free Pascal wiki, page "Div/es", as it stood on 2022-08-25 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 4, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.