Fawaz,

>I have a Unidata numeric field
>(Amount- 100.00 or -100.00) and I need to convert it
>to a 8 Bite integer so that Informix will recognise
>it.

Do you mean 8bit or 8byte?

For an 8 bit integer you need to output CHAR(n) where n is a number between
0 and 255.

For an 8 byte (64 bit) integer you would need to do something like this. I
aplogise if this isn't correct UD code, I usually work on UV. I am assuming
that the output integer is in MSB order and that the bits of each byte are
in MSb order.

ININT = 1145689
GOSUB MAKE8BYTE

STOP

MAKE8BYTE:
    * Initialise output as 0
    OUTINT = STR(CHAR(0), 8)

    FOR I = 1 TO 8
        * Get lowest 8bits
        LOWESTBYTE = BITAND(ININT, 255)
        * Convert this to a byte representation and place it in the output
integer
        OUTINT[8-I, 1] = CHAR(LOWESTBYTE)
        * Remove the lowest byte 8bits from the integer
        ININT = INT(ININT/256)
    NEXT I
RETURN

HTH,

Craig





-- 
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to