For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > Adding zero









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Adding zero
Danielle Woehrle

2008-01-31, 8:28 pm

I working on a binary program that requires strings of
zeros, I am able to get to work as long as the first digit
is a one, however when it is broken up into different bits,
the first digit is often a zero, and the program can't
continue to add to the zero, while keeping the zero in the
first location. (ie, 010 ends up as 10) is there anyway of
keeping that zero as a place holder?
Walter Roberson

2008-01-31, 8:28 pm

In article <fnttoh$efm$1@fred.mathworks.com>,
Danielle Woehrle <dnwoehrle@yahoo.com> wrote:
>I working on a binary program that requires strings of
>zeros, I am able to get to work as long as the first digit
>is a one, however when it is broken up into different bits,
>the first digit is often a zero, and the program can't
>continue to add to the zero, while keeping the zero in the
>first location. (ie, 010 ends up as 10) is there anyway of
>keeping that zero as a place holder?


How are you storing the values? From what you write, it
almost sounds as if you are trying to fake a bit stream
using base 10.

If you are using dec2bin() then consider using bitget() instead.[color=darkred]

ans =

10101101[color=darkred]

ans =

Columns 1 through 13

0 0 0 0 0 0 0 0 1 0 1 0 1

Columns 14 through 16

1 0 1


Note that bitget returns a numeric array where dec2bin returns
a character string.
--
"Is there any thing whereof it may be said, See, this is new? It hath
been already of old time, which was before us." -- Ecclesiastes
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com