Bottom Page

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'>
ljmetzger likes this post
Quote

Top Page

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
  floating point not increasing properly rakeshpe43 4 259 Apr-30-2020, 05:37 AM
Last Post: rakeshpe43
  Bytearray substitution Vismuto 1 107 Apr-14-2020, 09:18 AM
Last Post: TomToad
  connecting the first point to the last point Matplotlib omar_mohsen 0 255 Jan-15-2020, 01:23 PM
Last Post: omar_mohsen
  Complex floating issue arshad 2 981 Nov-05-2019, 03:26 PM
Last Post: arshad
  floating point arithmetic exDeveloper 2 286 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE
  finding the closest floating point number in a list Skaperen 17 1,112 Sep-19-2019, 10:39 PM
Last Post: Skaperen
  finding the next higher representable floating point value Skaperen 0 487 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  int() function with bytearray() Jona66 1 291 Sep-08-2019, 12:41 PM
Last Post: ichabod801
  Subtracting values between two dictionaries/ floating point numbers FloppyPoppy 5 1,527 Mar-04-2019, 01:00 PM
Last Post: snippsat
  Value error when converting hex value to bytearray shubhamjainj 3 1,073 Mar-01-2019, 08:29 AM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)