Here there is a good description of the COMP-3 fields:
http://www.discinterchange.com/TechT...d_fields_.html
It looks like it is a "packed" decimal representation: every byte contains
two decimal digits. The last byte contains the sign.
An unchecked function to convert a buffer may be this:
(Note that OutlookExpress does not compile this :-))
function PackedToDecimal(buffer() as byte) as decimal
dim result as decimal = 0
dim i as integer
dim b as byte
for i = 0 to buffer.length - 2
b = buffer(i)
result += (b and (&HF)) + ((b >> 4) * 10)
next
b = buffer(i)
r +=((b >> 4) * 10)
dim s as byte = (b and &HF)
if s = &HD Then
result = -result
end if
return r
end function
You will have to divide the result if it contains decimal digits.
Best Regards,
Alejandro Lapeyre
"Mythran" <(E-Mail Removed)> escribió en el mensaje
news:%(E-Mail Removed)...
> No Cobol.Net yet? Wha?!?
>
> Anywho, hope someone is familiar enough with Cobol to help me out here. I
> have some files written by COBOL applications that contain COMP-3 fields
> (on a mainframe) that I ftp up to a network folder for processing in .Net.
> Anyone know if it's possible (and how) to convert those COMP-3 (PIC
> S9(5)V99 COMP-3, for example) to a numeric of type double/single/et
> cetera?
>
> Hope so, as of now, I'm writing all the fix-it cob programs to convert on
> the mainframe before the ftp. If there is a .Net solution, that would be
> so much easier.
>
> Thanks,
>
> Mythran
>
>