Python Forum
Conversion needed from bytearray to Floating point
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Conversion needed from bytearray to Floating point
#2
Using struct should do it.
>>> import struct
>>> 
>>> b = bytearray(b'B\xc8\x00\x00')
>>> b
bytearray(b'B\xc8\x00\x00')

>>> f = struct.unpack('>f', b)
>>> f
(100.0,)
>>> f[0]
100.0
>>> type(f[0])
<class 'float'>
Reply


Messages In This Thread
RE: Conversion needed from bytearray to Floating point - by snippsat - May-07-2018, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Value error when converting hex value to bytearray shubhamjainj 7 10,486 Mar-20-2023, 05:30 PM
Last Post: Skaperen
  appending to a bytearray Skaperen 21 14,215 Mar-19-2023, 11:05 PM
Last Post: Skaperen
  Split Bytearray into separate Files by Hex delimter lastyle 5 2,631 Mar-09-2023, 07:49 AM
Last Post: bowlofred
  Save multiple Parts of Bytearray to File ? lastyle 1 939 Dec-10-2022, 08:09 AM
Last Post: Gribouillis
  bytearray object - why converting to ascii? Chepilo 2 1,613 Nov-21-2022, 07:25 PM
Last Post: Chepilo
  floating point not increasing properly rakeshpe43 4 2,386 Apr-30-2020, 05:37 AM
Last Post: rakeshpe43
  Bytearray substitution Vismuto 1 2,610 Apr-14-2020, 09:18 AM
Last Post: TomToad
  connecting the first point to the last point Matplotlib omar_mohsen 0 4,586 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen
  Complex floating issue arshad 2 11,827 Nov-05-2019, 03:26 PM
Last Post: arshad
  floating point arithmetic exDeveloper 2 2,108 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020