memmove() loses bits...

N

niko

Hi all,
I was working on bits and in the end moving them to another variabile
The original sequence is
00000000100011000000000000000000

while once moved with memmove() is

00000000000011000000000000000000

which is obviously different.

What could be the problem? Im moving bits from an unsigned to a float if
this may help.
thanx
 
A

Arthur J. O'Dwyer

Hi all,
I was working on bits and in the end moving them to another variabile
[and somehow ends up with different bits]

Post a small, compilable program that demonstrates the problem.
Also make sure to tell us the 'sizeof' all relevant types (you
mentioned unsigned short and float; how many bytes are they on
your platform?).

[If you use tabs in your source code, run it through
http://www.contrib.andrew.cmu.edu/~ajo/usenetify2.c
before posting. Otherwise it will turn out unreadable.]

-Arthur
 
K

Keith Thompson

niko said:
Hi all,
I was working on bits and in the end moving them to another variabile
The original sequence is
00000000100011000000000000000000

while once moved with memmove() is

00000000000011000000000000000000

which is obviously different.

What could be the problem? Im moving bits from an unsigned to a float if
this may help.

Some (short!) sample code would be helpful, but my best guess is that
the floating-point value is being normalized. The behavior may depend
on how you're retrieving the bits, which you don't show us.
 
B

Ben Pfaff

Arthur J. O'Dwyer said:
[If you use tabs in your source code, run it through
http://www.contrib.andrew.cmu.edu/~ajo/usenetify2.c
before posting. Otherwise it will turn out unreadable.]

blp@blp:~(0)$ wget http://www.contrib.andrew.cmu.edu/~ajo/usenetify2.c
--16:06:16-- http://www.contrib.andrew.cmu.edu/~ajo/usenetify2.c
=> `usenetify2.c'
Resolving www.contrib.andrew.cmu.edu... 128.2.4.154, 128.2.4.147
Connecting to www.contrib.andrew.cmu.edu[128.2.4.154]:80... connected.
HTTP request sent, awaiting response... 404 Not Found
16:06:17 ERROR 404: Not Found.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top