LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Bitoperations with floating point numbers


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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unacceptable floating point errors Jeff in GA Excel Discussion (Misc queries) 32 September 25th 09 11:26 AM
Floating point number comparison Edward Ulle Excel Programming 4 March 27th 06 04:13 PM
Floating point problem?? Frederick Chow Excel Programming 6 January 3rd 06 03:39 AM
setting a floating decimel point Rose New Users to Excel 2 April 29th 05 06:10 PM
Floating Point Functions Joel Excel Programming 6 March 30th 05 10:29 PM


All times are GMT +1. The time now is 01:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"