Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. IntegerToHex Wrongly Converting Negative Integers

integerToHex wrongly converting negative integers

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
Profile picture for user Kurumi

Kurumi

7 years 5 months ago

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

zmiguel

7 years 5 months ago

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.

Profile picture for user Administrator

Administrator

6 years 8 months ago

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Thu, 11/19/2026 - 10:57
    Gurux.DLMS.Python 1.0.204
  • Thu, 11/19/2026 - 10:12
    gurux.dlms.c 9.0.2611.1901
  • Tue, 10/13/2026 - 12:00
    gurux.dlms.java 4.0.97
  • Tue, 09/22/2026 - 14:02
    Gurux.DLMS.Net 9.0.2609.2201
  • Mon, 09/21/2026 - 10:18
    Gurux.DLMS.Net 9.0.2609.2101

New forum topics

  • Landis E650 meter reading over DLMS
  • class_id = 40, version = 2, pushsetup Unparsed data frame
  • GXObisValueItem entries without MaskSize appear to be interpreted as bit flags
  • CheckedListBox incorrectly selects GXObisValueItem Value=0 for non-zero values
  • UIValueType=TextBox is rendered as CheckedListBox when Values are defined
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin