How display integer bigger than 2.147.483.647

Hello!
In a grid-field, I have to display numbers bigger than 2.147.483.647. The value is stored in database as B4. When I redefine to I4 (integer 4) I can not display values bigger than from -2.147.483.647 to 2.147.483.647. How is it possible to change this integer typ to 0 to 4.294.967.295 (signed/unsigned)?

Thank you very much!
Matthias

Not possible, Natural does not have “unsigned” integer types.

You would have to circumvent this by calling an external routine and convert your B4 to
a data type allowing for values exceeding those of a signed I4.

Took me a couple of minutes to test this code.

DEFINE DATA LOCAL
1 #BIN (B4)  INIT <H'FFFFFFFF'>
1 #PACKED (P11)
END-DEFINE
ASSIGN #PACKED = #BIN
IF  #PACKED < 0
  THEN
    ASSIGN #PACKED = #PACKED + 4294967296
END-IF
DISPLAY #BIN #PACKED
END
Page     1                                                   09082017  08:51:57
 
  #BIN     #PACKED
-------- ------------
 
FFFFFFFF   4294967295

That !

… I didn’t know, I have to admit.

To complete the picture:


DEFINE DATA LOCAL            
1 #B1  (B1)  INIT <H'FF'>    
1 #B2  (B2)  INIT <H'FFFF'>  
1 #B3  (B3)  INIT <H'FFFFFF'>
1 #PACKED (P21)              
END-DEFINE                   
ASSIGN #PACKED = #B1         
WRITE #PACKED                
*                            
ASSIGN #PACKED = #B2         
WRITE #PACKED                
*                            
ASSIGN #PACKED = #B3         
WRITE #PACKED                
*                            
END                          
                255
           65535
    16777215

Doesn’t work for anything above B4, and B4 is a special case as it is treated as “signed” while B1 or B2 are not.

You said you wanted to display bigger numbers. There is a feature in Natural that is rarely used. The result of a numeric computation can be stored in an alpha field, as shown below:

DEFINE DATA LOCAL
1 #BIN (B4) INIT <H’FFFFFFFF’>
1 #PACKED (P11)
1 #alpha (a20)
END-DEFINE
include aasetc
ASSIGN #PACKED = #BIN
IF #PACKED < 0
THEN
ASSIGN #PACKED = #PACKED + 4294967296
END-IF
DISPLAY #BIN #PACKED
compute #alpha = #packed + 1234567890
write // ‘=’ #alpha
END

Page 1 17-09-09 05:52:44

#BIN #PACKED


FFFFFFFF 4294967295

#ALPHA: 5529535185

thank you so much for your helping hand! :wink:
I’ll try and answer

Matthias