IBM / db2sock-ibmi

An asynchronous PASE Db2 and IBM i integration library
MIT License
4 stars 7 forks source link

Negative numbers don't work #17

Closed kadler closed 6 years ago

kadler commented 6 years ago

Original report by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Negative numbers doesn't seems to work.

     H AlwNull(*UsrCtl)

       dcl-pr Main extpgm;
         aint8 int(3);
         aint16 int(5);
         aint32 int(10);
         aint64 int(20);
         afloat float(4);
         adouble float(8);
         apacked packed(12:2);
         azonded zoned(12:2);
       end-pr;

       dcl-pi Main;
         aint8 int(3);
         aint16 int(5);
         aint32 int(10);
         aint64 int(20);
         afloat float(4);
         adouble float(8);
         apacked packed(12:2);
         azonded zoned(12:2);
       end-pi;
         aint8 -= 10;
         aint16 -= 10;
         aint32 -= 10;
         aint64 -= 10;
         afloat -= 10.11;
         adouble -= 10.111;
         apacked -= 10.11;
         azonded -= 10.11;
       return;
$ ./test1000_sql400json32 ../json/j0020_negative_numbers                                                                                                       
input(5000000):                                                                                                                                                                    
{"pgm":[{"name":"NEGATIVE",  "lib":"DB2JSON"},
        {"s":[{"name":"aint8",      "type":"3i0",   "value":-1},
              {"name":"aint16",     "type":"5i0",   "value":-2},
              {"name":"aint32",     "type":"10i0",  "value":-3},
              {"name":"aint64",     "type":"20i0",  "value":-4},
              {"name":"afloat",     "type":"4f2",   "value":-5.55},
              {"name":"adouble",    "type":"8f3",   "value":-6.666},
              {"name":"apacked",    "type":"12p2",  "value":-7.77},
              {"name":"azoned",     "type":"12s2",  "value":-8.88}
             ]}
       ]}

output(167):
{"script":[{"pgm":["NEGATIVE","DB2JSON",{"aint8":-9},{"aint16":-8},{"aint32":-7},{"aint64":-6},{"afloat":-4.56},{"adouble":-3.445},{"apacked":2.34},{"azoned":1.23}]}]}

result:
fail missing ("aint8":-11)
fail (-1)

Ints and floats seem to return negatives correctly, but they seem to lose the sign when sending. Packed and zoned also won't return negative number.

Test files can be found in my fork.

kadler commented 6 years ago

Original comment by Teemu Halmela (Bitbucket: teemu_, GitHub: Unknown).


Thank you, negative numbers are fixed now.

kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


negative

Ok, fix available.

#!bash

bash-4.3$ cd tests/c
bash-4.3$ ./test1000_sql400json32 ../json/j0193_pgm_hamela07-negative    
input(5000000):
{"pgm":[{"name":"HAMELA07",  "lib":"DB2JSON"},
        {"s":[{"name":"aint8",      "type":"3i0",   "value":-1},
              {"name":"aint16",     "type":"5i0",   "value":-2},
              {"name":"aint32",     "type":"10i0",  "value":-3},
              {"name":"aint64",     "type":"20i0",  "value":-4},
              {"name":"afloat",     "type":"4f2",   "value":-5.55},
              {"name":"adouble",    "type":"8f3",   "value":-6.666},
              {"name":"apacked",    "type":"12p2",  "value":-7.77},
              {"name":"azoned",     "type":"12s2",  "value":-8.88}
             ]}
       ]}

output(177):
{"script":[{"pgm":["HAMELA07","DB2JSON",{"aint8":-11},{"aint16":-12},{"aint32":-13},{"aint64":-14},{"afloat":-15.66},{"adouble":-16.777},{"apacked":-17.88},{"azoned":-18.99}]}]}

result:
success (0)
kadler commented 6 years ago

Original comment by Tony Cairns (Bitbucket: rangercairns, GitHub: rangercairns).


Ints and floats seem to return negatives correctly, but they seem to lose the sign when sending. Packed and zoned also won't return negative number.

I will take a look.

BTW -- only work Mon-Wed (part time).