By zmiguel , 17 June, 2019 Project Gurux.DLMS.Python Status Closed (fixed) integerToHex method of _GXCommon.py is wrongly converting negative integers to hex. For instance, -4 should be converted to FC, however it is converting it to X4. This is happening due to str_ = hex(value)[2:] line, as hex(-4) is '-0x4'. Priority Normal Category Bug report integerToHex wrongly converting negative integers Hi, This is verified and you are right. hex -method is Python standard method: https://docs.python.org/3/library/functions.html#hex We make own implementation from this. We'll update a new version on next week. BR, Mikko Hi, Hi, You can find a working example here: https://gist.github.com/i96751414/b1ed2aef2cb9f602d03c305e22cb6e13 It takes into account negative numbers. Also, just noticed that method integerString might be wrong for negative numbers. Please have a look at the implementation in the above gist.
integerToHex wrongly converting negative integers Hi, This is verified and you are right. hex -method is Python standard method: https://docs.python.org/3/library/functions.html#hex We make own implementation from this. We'll update a new version on next week. BR, Mikko
Hi, Hi, You can find a working example here: https://gist.github.com/i96751414/b1ed2aef2cb9f602d03c305e22cb6e13 It takes into account negative numbers. Also, just noticed that method integerString might be wrong for negative numbers. Please have a look at the implementation in the above gist.
integerToHex wrongly converting negative integers
Hi,
This is verified and you are right. hex -method is Python standard method:
https://docs.python.org/3/library/functions.html#hex
We make own implementation from this. We'll update a new version on next week.
BR,
Mikko
Hi,
Hi,
You can find a working example here:
https://gist.github.com/i96751414/b1ed2aef2cb9f602d03c305e22cb6e13
It takes into account negative numbers.
Also, just noticed that method integerString might be wrong for negative numbers. Please have a look at the implementation in the above gist.