Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, form my point of view, I'm haveing a really tiny problem, but I am not able to solve it by myself. My final goal is to be able to split 32bit floating point variables (as Sinlgle) binary into 4 seperate bytes (which is necessary to work with a given transmission protocol). Therefor I am trying to read and write single bits in a floating point variable (e.g. Single). I already succeeded with 32bit variables of the type Long. So my problem would already be solved, if you can help me to write the 32 bits of the 32bit Single variable bitwise into the 32 bits of a 32bit Long variable. Code: -------------------- dim s as Single 'dim s as Long Dim bit(0 To 30) As Boolean s = 12.34 's = 12 For j = 0 To 30 bit(j) = CBool(s And 2 ^ j) Next j -------------------- This code works fine for the commented line, when the variable s is of type Long. When s is of type Single, VB automaticly casts the 12.34 to an Integervalue of 12. So how can I split (and recombine) the 32bit Singlevalue into Bytes (8bit)? Thanks in advance for your effort, Parity -- Parity ------------------------------------------------------------------------ Parity's Profile: http://www.excelforum.com/member.php...o&userid=25023 View this thread: http://www.excelforum.com/showthread...hreadid=530721 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unacceptable floating point errors | Excel Discussion (Misc queries) | |||
Floating point number comparison | Excel Programming | |||
Floating point problem?? | Excel Programming | |||
setting a floating decimel point | New Users to Excel | |||
Floating Point Functions | Excel Programming |