Cobol Foro
Navegación en el Foro
Retroceder   Cobol Foro Entornos de desarrollo y compiladores Cobol COBOL - General
COBOL - General Discusiones de temática general sobre el lenguaje COBOL y todo lo relacionado con él.
 
Otros temas que te pueden interesar
Tema Autor Foro Respuestas Último post
[Sintaxis] Campos numericos en SQL Server Fito PowerCOBOL (ActiveX, v4 - v11) 4 17 de septiembre de 2020 09:02
[Sintaxis] Campos tipo BLOB mysql atncasiello PowerCOBOL (ActiveX, v4 - v11) 2 8 de diciembre de 2018 13:25
Equivalente COBOL a campos Numeric(15,6) Hrmcobol Bases de datos 7 3 de febrero de 2016 08:53
[Sintaxis] Campos VARBINARY ó BLOB en COBOL Josber COBOL - General 4 3 de diciembre de 2015 13:26
[Sintaxis] Valores numericos y editados Breew PowerCOBOL (ActiveX, v4 - v11) 18 31 de marzo de 2015 16:33

Respuesta
 
Herramientas

  #1
Antiguo 28 de enero de 2016, 18:55
Galileo
Forero Junior
Última Actividad 22.01.2021 11:39
Posts Posts: 38
Likes enviados Enviados: 20
Likes recibidos Recibidos: 41
Relación de tablas Equivalencia de formato de campos numéricos
1 Inactivo Inactivo

Hola.

Hace un tiempo, en mis añorados foros de ESCOBOL alguien publicó una gran aportación: la equivalencia de los campos numéricos BYTE, SINGLE, DOUBLE, INTEGER, LONG, etc. en COBOL. Si alguien tuvo la precaución de guardar esta información o sabe donde puedo encontrarla, estoy interesado en conseguirla.

Un saludo.

---------- Post añadido : 18:55 ---------- Post anterior : 18:09 ----------

Vale, yo mismo me respondo. Debería de haber consultado primero en Internet. Mea culpa.

En la página http://documentation.microfocus.com/...BBD971DA4.html he encontrado una tabla de conversión.

En el sitio de Microsoft, esta es la información que se puede encontrar:

Supported COBOL Data Types

COMP-1
A 4-byte, single precision, floating-point Real data type that specifies internal floating-point items. The sign is contained in the first bit of the leftmost byte, and the exponent is contained in the remaining seven bits of that byte. The remaining three bytes hold the mantissa.
COMP-2
An 8-byte, double precision, floating-point Real data type that specifies internal floating-point items. The sign is contained in the first bit of the leftmost byte, and the exponent is contained in the remaining seven bits of the first byte. The remaining seven bytes hold the mantissa.
COMP-3 Packed Decimal
A packed decimal data type that specifies internal decimal items stored in packed decimal format. In the packed decimal format, each byte in a field represents two numeric digits except for the rightmost byte. The rightmost byte holds one digit and the sign. In other words, there are two digits in each character position except for the trailing character position that is occupied by the low-order digit and sign. The item can contain any of the digits from 0 through 9, plus a sign, to represent a value not exceeding 18 decimal digits. For example, the decimal value +123 is represented in two bytes as 0001 0010 0011 1100 in packed decimal format. For more information see, Zoned Decimal or Packed Decimal Data Types.
DISPLAY Zoned Decimal
An unpacked decimal data type that specifies internal decimal items stored in zoned decimal format. Zoned decimal format is synonymous with unpacked decimal format, which is a format for representing numbers where each digit is contained in bits 4 through 7 and the sign is contained in bits 0 through 3 of the least significant byte. Bits 0 through 3 of all bytes other than the least significant byte contain 1s (hex F). For example, the decimal value +123 is represented in three bytes as 1111 0001 1111 0010 1100 0011 in zoned decimal format. For more information see, Zoned Decimal or Packed Decimal Data Types.
DATE and TIME
Specifies a date and time by using group item of two PIC 9(7) COMP-3 Packed Decimal value.
TIME only
Specifies a time by using a PIC 9(7) COMP-3 Packed Decimal value.
DATE only
Specifies a date by using a PIC 9(7) COMP-3 Packed Decimal value.
PIC X
Specifies a single character in an Extended Binary Coded Decimal Interchange Code (EBCDIC) character string. EBCDIC is the native representation for character data on mainframes and AS/400s. Unicode is the native representation for character data on Windows-based platforms.
PIC X No Translation
Specifies a single COBOL character in an EBCDIC character string that is handled as if it were binary data. In other words, there is no translation from EBCDIC to Unicode or from Unicode to EBCDIC.
PIC G
Specifies a double-byte EBCDIC string.
PIC S9(4) COMP (Integer 16-bit)
Specifies an integer that is 16 bits, or 2 bytes, in length.
PIC S9(9) COMP (Integer 32-bit)
Specifies an integer that is 32 bits, or 4 bytes, in length.
Galileo is offline   Responder Con Cita
  #2
Antiguo 29 de enero de 2016, 09:19
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

A todo esto puedo añadir lo siguiente: COMP y COMP-4 equivalen y son campos binarios independientes de la máquina. Pero hay una diferencia entre los binarios COBOL y el binario "nativo" que es el COMP-5 y sí es dependiente de la máquina. A diferencia de binarios COBOL, el binario "nativo" puede contener cifras superiores al valor PIC.

Por ejemplo, un PIC S9(4) COMP puede contener de -9999 hasta 9999. Sin embargo PIC S9(4) COMP-5 puede contener de -32768 hasta 32767.

Para comunicarnos con el SO u otro software como rutinas C/C++ etc., normalmente se debe usar el binario nativo COMP-5.

Resumiendo:

Código COBOL:
  1. Tipo                COBOL              Tamaño   Valores posibles
  2. -----------------------------------------------------------------------------------------------------------
  3. SHORT               PIC S9(4) COMP-5   2 Bytes  De -32,768                    a 32,767
  4. USHORT              PIC  9(4) COMP-5   2 Bytes  De 0                          a 65,535
  5. INT                 PIC S9(9) COMP-5   4 Bytes  De -2,147,483,648             a 2,147,483,647
  6. UINT                PIC  9(9) COMP-5   4 Bytes  De 0                          a 4,294,967,295
  7. INT64               PIC S9(18) COMP-5  8 Bytes  De –9,223,372,036,854,775,808 a 9,223,372,036,854,775,807
  8. UINT64              PIC  9(18) COMP-5  8 Bytes  De 0                          a 18,446,744,073,709,551,615
  9. LONG  en Windows    INT                4 Bytes  De -2,147,483,648             a 2,147,483,647
  10. ULONG en Windows    UINT               4 Bytes  De 0                          a 4,294,967,295
  11. LONG  en Linux x64  PIC S9(18) COMP-5  8 Bytes  De –9,223,372,036,854,775,808 a 9,223,372,036,854,775,807
  12. ULONG en Linux x64  PIC  9(18) COMP-5  8 Bytes  De 0                          a 18,446,744,073,709,551,615
  13. FLOAT               COMP-1             4 Bytes  De 1.2E-38                    a 3.4E+38  
  14. DOUBLE              COMP-2             8 Bytes  De 2.3E-308                   a 1.7E+308
  15. *     en x86        POINTER            4 Bytes  De -2,147,483,648             a 2,147,483,647
  16. *     en x64        POINTER            8 Bytes  De –9,223,372,036,854,775,808 a 9,223,372,036,854,775,807



NORMAS DEL FORO - para garantizar el buen funcionamiento del Foro.
¿Te han ayudado? NO TE OLVIDES de darle a
¿Quieres dirigirte a alguien en tu post? Notifícale haciendo clic en su Nick
Kuk is offline   Responder Con Cita
Respuesta



Derechos de Publicación
No puedes publicar nuevos temas
No puedes publicar posts/responder
No puedes adjuntar archivos
No puedes editar tus posts

BB code is habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado

Saltar a Foro


La franja horaria es GMT +2. Ahora son las 13:55.
Powered by: vBulletin, Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.