https://wiki.freepascal.org/api.php?action=feedcontributions&user=Jonatanpc8&feedformat=atomLazarus wiki - User contributions [en]2024-03-28T23:50:46ZUser contributionsMediaWiki 1.35.6https://wiki.freepascal.org/index.php?title=Byte&diff=135200Byte2020-04-05T00:18:19Z<p>Jonatanpc8: </p>
<hr />
<div>{{Byte}}<br />
<br />
A <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> is an unsigned [[Integer|<syntaxhighlight lang="pascal" enclose="none">integer</syntaxhighlight>]] in the range of <syntaxhighlight lang="pascal" enclose="none">0..255</syntaxhighlight>.<br />
A <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> is 8&nbsp;bits long.<br />
A <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> and a [[Char|<syntaxhighlight lang="pascal" enclose="none">char</syntaxhighlight>]] are virtually the same thing as of version&nbsp;3 of [[FPC]].<br />
<br />
== valid values ==<br />
The key difference is, a <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> can only be referred to as a numeric [[Type|<syntaxhighlight lang="pascal" enclose="none">type</syntaxhighlight>]], while a <syntaxhighlight lang="pascal" enclose="none">char</syntaxhighlight> can be used as a character, or as part of a string type, and cannot be used in an arithmetic expression.<br />
A <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> will always be the same size as an [[AnsiChar|<syntaxhighlight lang="pascal" enclose="none">ansiChar</syntaxhighlight>]], but in the future <syntaxhighlight lang="pascal" enclose="none">char</syntaxhighlight> may be considered a synonym for [[WideChar|<syntaxhighlight lang="pascal" enclose="none">wideChar</syntaxhighlight>]], not <syntaxhighlight lang="pascal" enclose="none">ansiChar</syntaxhighlight>.<br />
<br />
For example:<br />
<syntaxhighlight lang="pascal"><br />
program byteDemo(input, output, stderr);<br />
<br />
var <br />
foo: byte;<br />
bar: char;<br />
<br />
begin<br />
// those two assignments are physically the same<br />
foo := 65;<br />
bar := 'A';<br />
<br />
// although they are the same action,<br />
// the following would be illegal<br />
//foo := 'A';<br />
//bar := 65;<br />
end.<br />
</syntaxhighlight><br />
<br />
The use of <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> or <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> as a data type provides better documentation as to the purpose of the use of the particular variable.<br />
<br />
== standard functions ==<br />
=== conversion to and from character ===<br />
The <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> type can be [[coersion|coerced]] to <syntaxhighlight lang="pascal" enclose="none">char</syntaxhighlight> by using the [[Chr|<syntaxhighlight lang="pascal" enclose="none">chr</syntaxhighlight> function]].<br />
Char type values can be coerced to byte by using the [[Ord|<syntaxhighlight lang="pascal" enclose="none">ord</syntaxhighlight> function]].<br />
<br />
The above program corrected to legal use:<br />
<syntaxhighlight lang="pascal"><br />
program ordChrDemo(input, output, stderr);<br />
<br />
var<br />
foo: byte;<br />
bar: char;<br />
<br />
begin<br />
foo := 65;<br />
bar := 'A';<br />
<br />
foo := ord('A');<br />
// chr(65) is equivalent to #65<br />
bar := chr(65);<br />
bar := #65;<br />
<br />
// alternatively: typecasts<br />
// typecasts of constant expressions<br />
// are guaranteed to happen at compile-time<br />
foo := byte('A');<br />
bar := char(65);<br />
end.<br />
</syntaxhighlight><br />
<br />
=== string representation ===<br />
The {{Doc|package=RTL|unit=system|identifier=binstr|text=<syntaxhighlight lang="pascal" enclose="none">binStr</syntaxhighlight> function}} from the [[System unit|<syntaxhighlight lang="pascal" enclose="none">system</syntaxhighlight> unit]] can be used to get a [[String|<syntaxhighlight lang="pascal" enclose="none">string</syntaxhighlight>]] showing the [[Binary numeral system|binary representation]] of a <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight>:<br />
<br />
<syntaxhighlight lang="pascal"><br />
program binStrDemo(input, output, stderr);<br />
<br />
var<br />
foo: byte;<br />
<br />
begin<br />
foo := 10;<br />
writeLn(binStr(foo, 8));<br />
end.<br />
</syntaxhighlight><br />
The output is:<br />
<syntaxhighlight lang="text"><br />
00001010<br />
</syntaxhighlight><br />
A more versatile function is {{Doc|package=RTL|unit=strutils|identifier=inttobin|text=<syntaxhighlight lang="pascal" enclose="none">intToBin</syntaxhighlight> provided by the <syntaxhighlight lang="pascal" enclose="none">strUtils</syntaxhighlight> unit}}.<br />
<br />
<br />
{{Data types}}</div>Jonatanpc8https://wiki.freepascal.org/index.php?title=Byte/es&diff=135199Byte/es2020-04-04T22:08:10Z<p>Jonatanpc8: Creacion de pagina Byte/es y traduccion del contenido de ingles a español</p>
<hr />
<div>{{Byte}}<br />
Un byte es un [[Integer/es|entero]] sin signo en el rango de 0..255. Un byte tiene 8 bits de longitud. Un byte y un [[Char/es|char]] son prácticamente lo mismo que en la versión 3 de [[FPC]].<br />
<br />
== Valores validos ==<br />
La diferencia clave es que un byte solo se puede designarse como un tipo numérico, mientras que un [[Char/es|char]] se puede usar como un carácter o como parte de un tipo de cadena y no se puede usar en una expresión aritmética. Un byte siempre tendrá el mismo tamaño que un [[AnsiChar/es|ansiChar]], pero en el futuro [[Char/es|char]] puede considerarse un sinónimo de [[WideChar/es|wideChar]], no [[AnsiChar/es|ansiChar]].<br />
<br />
Por Ejemplo:<br />
<br />
<syntaxhighlight lang="pascal"><br />
program byteDemo(input, output, stderr);<br />
<br />
var <br />
foo: byte;<br />
bar: char;<br />
<br />
begin<br />
// Las dos asignaciones son basicamente iguales<br />
foo := 65;<br />
bar := 'A';<br />
<br />
// Aunque son el mismo valor,<br />
// la siguiente asignacion sería ilegal<br />
//foo := 'A';<br />
//bar := 65;<br />
end.<br />
</syntaxhighlight><br />
<br />
El uso de <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> como tipo de datos proporciona una mejor documentación en cuanto al propósito del uso de la variable particular.<br />
<br />
== Funciones estandar ==<br />
=== Conversión hacia y desde el caracter ===<br />
<br />
El tipo de <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> se puede convertir a [[Char/es|char]] mediante la [[Chr/es|<syntaxhighlight lang="pascal" enclose="none">función chr</syntaxhighlight>]]. Los valores de tipo [[Char/es|char]] se pueden forzar a <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight> utilizando la [[Ord/es|<syntaxhighlight lang="pascal" enclose="none">función ord</syntaxhighlight>]].<br />
<br />
El programa anterior corregido para uso legal:<br />
<br />
<syntaxhighlight lang="pascal"><br />
program ordChrDemo(input, output, stderr);<br />
<br />
var<br />
foo: byte;<br />
bar: char;<br />
<br />
begin<br />
foo := 65;<br />
bar := 'A';<br />
<br />
foo := ord('A');<br />
// chr(65) es equivalente a #65<br />
bar := chr(65);<br />
bar := #65;<br />
<br />
// Alternativamente: typecasts / tipos de conversión<br />
// typecasts de expresiones constantes<br />
// se garantiza que se produzca en tiempo de compilación<br />
foo := byte('A');<br />
bar := char(65);<br />
end.<br />
</syntaxhighlight><br />
<br />
=== Representación de cadena ===<br />
<br />
La {{Doc|package=RTL|unit=system|identifier=binstr|text=<syntaxhighlight lang="pascal" enclose="none">función binStr</syntaxhighlight> }} de la [[System_unit/es|unidad del sistema]] se puede usar para obtener una cadena que muestra la representación binaria de un <syntaxhighlight lang="pascal" enclose="none">byte</syntaxhighlight>:<br />
<br />
<syntaxhighlight lang="pascal"><br />
program binStrDemo(input, output, stderr);<br />
<br />
var<br />
foo: byte;<br />
<br />
begin<br />
foo := 10;<br />
writeLn(binStr(foo, 8));<br />
end.<br />
</syntaxhighlight><br />
<br />
La salida es:<br />
<syntaxhighlight lang="text"><br />
00001010<br />
</syntaxhighlight><br />
<br />
Una función más versátil es {{Doc|package=RTL|unit=strutils|identifier=inttobin|text=<syntaxhighlight lang="pascal" enclose="none">intToBin</syntaxhighlight> proporcionada por <syntaxhighlight lang="pascal" enclose="none">strUtils</syntaxhighlight> unit}}.<br />
<br />
{{Data types}}</div>Jonatanpc8https://wiki.freepascal.org/index.php?title=Data_type/es&diff=118984Data type/es2018-08-31T17:00:15Z<p>Jonatanpc8: Traduccion del contenido Data types a español</p>
<hr />
<div>{{Data type}}<br />
<br><br />
=General=<br />
Esta página proporciona una variedad de tipos de datos en Free Pascal. <br><br />
Un tipo de datos es una plantilla para un campo de datos. <br><br />
El '''tipo de datos''' de un campo define cómo el compilador y el procesador interpretan su contenido.<br><br />
La visibilidad de un campo de datos depende de la ubicación de su declaración.<br />
<br><br />
<br><br />
<br />
=Tipos enteros=<br />
==Tipos unsigned==<br />
Los campos de datos de tipos enteros unsigned o sin signo sólo pueden contener '''números enteros positivos'''. <br />
* [[UInt8]] - Rango: (0 .. 255)<br />
* [[Byte]] - Rango: (0 .. 255)<br />
* [[UInt16]] - Rango: (0 .. 65535)<br />
* [[Word]] - Rango: (0 .. 65535)<br />
* [[NativeUInt]] - Rango: depende del tipo de procesador.<br />
* [[DWord]] - es equivalente a Longword.<br />
* [[Cardinal]] - es equivalente a Longword.<br />
* [[UInt32]] - Rango: (0 .. 4294967295)<br />
* [[Longword]] - Rango: (0 .. 4294967295)<br />
* [[UInt64]] - Rango: (0 .. 18446744073709551615)<br />
* [[QWord]] - Rango: (0 .. 18446744073709551615)<br />
<br><br />
<br />
==Tipos signed==<br />
Los campos de datos de tipos enteros con signo, pueden contener números enteros positivos y negativos.<br />
* [[Int8]] - Rango: (-128 .. 127)<br />
* [[Shortint|ShortInt]] - Rango: (-128 .. 127)<br />
* [[Int16]] - Rango: (-32768 .. 32767)<br />
* [[Smallint|SmallInt]] - Rango: (-32768 .. 32767) <br />
* [[Integer]] - Rango: es equivalente también a Smallint o Longint (para 16 procesadores de 32 bit respectivamente).<br />
* [[Int32]] - Rango: (-2147483648 .. 2147483647)<br />
* [[NativeInt]] - Rango: depende del tipo de procesador.<br />
* [[Longint]] - Rango: (-2147483648 .. 2147483647)<br />
* [[Int64]] - Rango: (-9223372036854775808 .. 9223372036854775807)<br />
<br><br />
<br />
=Tipos de punto flotante=<br />
Los campos de datos de un tipo de punto flotante pueden contener:<br />
# Números enteros positivos y negativos con posibles errores de redondeo.<br />
# Números de punto flotante positivo y negativo.<br />
<br><br />
* [[Single]] - Rango: (1.5E-45 .. 3.4E38)<br />
* [[Real]] - Rango: depende de la plataforma.<br />
* [[Real48]] - Rango: 2.9E-39 .. 1.7E38<br />
* [[Double]] - Rango: (5.0E-324 .. 1.7E308)<br />
* [[Extended]] - Rango: depende de la plataforma.<br />
* [[Comp]] - Rango: (-2E64+1 .. 2E63-1)<br />
* [[Currency]] - Rango: (-922337203685477.5808 .. 922337203685477.5807)<br />
<br><br />
<br />
=Tipos booleanos=<br />
Los campos de datos de tipo booleano contienen valores de verdad.<br />
* [[Boolean]] - Rango: (True, False), 8 Bit<br />
* [[Bytebool|ByteBool]] - Rango: (True, False), 8 Bit<br />
* [[Wordbool|WordBool]] - Rango: (True, False), 16 Bit<br />
* [[Longbool|LongBool]] - Rango: (True, False), 32 Bit<br />
<br><br />
=Tipos enumerados=<br />
Los campos de datos de un tipo de enumerado son "listas" (enumeraciones ...) de constantes sin signo enteras.<br />
* [[Enum Type]] - Rango: (tipos de datos enteros)<br />
<br><br />
<br />
=Tipos char=<br />
==Tipos de caracteres con codificación de un solo byte==<br />
* [[Char]] - Longitud constante: 1 byte, representación: 1 carácter.<br />
* [[Shortstring|ShortString]] - Longitud máxima: 255 caracteres.<br />
* [[String]] - Longitud máxima: Shortstring o Ansistring (depende del switch del compilador usado).<br />
* [[PChar]] - Puntero a una cadena terminada en NULL sin restricción de longitud.<br />
* [[Ansistring|AnsiString]] -Sin restricción de longitud.<br />
* [[Pansichar|PAnsiChar]] - Puntero a una cadena terminada en NULL sin restricción de longitud.<br />
Consulte la descripción general de los diferentes [[Character and string types/es]].<br />
<br><br />
<br />
== Tipos de caracteres con codificación de bytes múltiples==<br />
(La codificación con 2 o 4 bytes depende del sistema.<br><br />
* [[Widechar|WideChar]] - Longitud constante: 2 o 4 bytes, representación: 1 carácter.<br />
* [[Widestring|WideString]] - Sin restricción de longitud.<br />
* [[Pwidechar|PWideChar]] - Puntero a una cadena grande terminada en NULL sin restricción de longitud.<br />
* [[Unicodechar|UnicodeChar]] - Longitud constante: 2 o 4 bytes, representación: 1 carácter.<br />
* [[Unicodestring|UnicodeString]] -Sin restricción de longitud.<br />
* [[Punicodechar|PUnicodeChar]] - Puntero a una cadena Unicode terminada en NULL sin restricción de longitud.<br />
Consulte la descripción general de los diferentes [[Character and string types/es]]<br />
<br><br />
<br />
=Tipos de variantes=<br />
*[[Variant]]<br />
*[[Olevariant]]<br />
<br><br />
<br />
=Constantes=<br />
*Constantes untyped <br />
**[[Const]] - Solo se pueden usar tipos de datos simples.<br />
*Constantes typed <br />
**[[Const]] - Se pueden usar tipos de datos simples, así como registros y matrices.<br />
*Resource Strings<br />
**[[Resourcestring|Resourcestring]] -Usado para localización (no disponible en todos los modos de compilación).<br />
<br><br />
<br />
=Tipos estructurales=<br />
* [[Array]] - El tamaño de la matriz depende del tipo y la cantidad de elementos que contiene.<br />
* [[Record]] - Una combinación de múltiples tipos de datos.<br />
* [[Set]] - Un conjunto de elementos de un tipo ordinal; el tamaño depende del número de elementos que contiene.<br />
<br><br />
<br />
=Tipos de subrango=<br />
* Los tipos de subrango son un subconjunto de un tipo base.<br />
<br><br />
<br />
=Puntero=<br />
* [[Pointer]] -El tamaño depende del tipo de procesador.<br />
<br><br />
<br />
=Clases y objetos=<br />
* [[Object]] - Desarrollado bajo Turbo Pascal 5.5 para DOS y el precursor de clase.<br />
* [[Class]] - Desarrollado bajo Delphi 1.0 para Windows y el sucesor del objeto.<br />
<br><br />
<br><br />
{{AutoCategory}}[[Category:Data types]]<br />
<br />
--[[User:Jonatanpc8|Jonatanpc8]] ([[User talk:Jonatanpc8|talk]]) 19:00, 31 August 2018 (CEST)jonatanpc8</div>Jonatanpc8