I made some tests on bit manipulation functions and I think I've found some bugs in them (Gambas 2.12.0).
I read in the documentation that a function like SHL should keep care of the initial type of data. I.e., if I use a byte, it should work using 8 bits (the lenght of a byte), if I use an integer it should work using 32 bits and so on.... But I see that this is not the way it works. If you try SHL(197,3) you would think to espect 46 as result. Instead, you get 1576! 197 in binary format is 11000101, so a shift of 3 bit should give a result of 00101000 (40). It seems that the function doesn't check the initial type of the received data (in the example the byte type, with a lenght of 8 bits) and simply rolls on the left the bit, adding some zeros to the right. In fact, 1576 is 11000101000 in binary format, just the original number of 11000101 plus 3 zeros on the right. Same behaviour with ROL function. ROL(197,3) should give a result of 46 (00101110) but I still continue to get as result the value of 1576 (11000101 plus 3 zeros on the right)! -- Leonardo Miliani Web: http://www.leonardomiliani.com E-mail: leona...@leonardomiliani.com Scegli software opensource - Choose opensource software Co-fondatore di Gambas-it.org Il sito di riferimento della comunità italiana degli utenti di Gambas http://www.gambas-it.org ------------------------------------------------------------------------------ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user