By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,251 Members | 2,727 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,251 IT Pros & Developers. It's quick & easy.

how to convert data from string to nibble

P: n/a
i need to convert data from string to nibble wich (nibble is a four bits
representation)

As example i have the following code

string data1 = "12345678";

so ┬┐how can i convert this data (numbers) to a nibble representation?

thanks for any idea
Jul 13 '07 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi,
"Ricardo Quintanilla" <Ri****************@discussions.microsoft.comwro te
in message news:9A**********************************@microsof t.com...
>i need to convert data from string to nibble wich (nibble is a four bits
representation)

As example i have the following code

string data1 = "12345678";

so ┐how can i convert this data (numbers) to a nibble representation?
how do y ou want to keep the nibble? do u have a class for that?

You can convert it to int and extract the nibble of each digit
Jul 13 '07 #2

P: n/a
On Fri, 13 Jul 2007 06:52:01 -0700, Ricardo Quintanilla
<Ri****************@discussions.microsoft.comwrote :
i need to convert data from string to nibble wich (nibble is a four bits
representation)

As example i have the following code

string data1 = "12345678";

so ┬┐how can i convert this data (numbers) to a nibble representation?
Your question is too vague to be answered.

First, the question is when you write "this data (numbers)", what exactly
is the data you want to convert _from_? Do the numbers represent an
actual integer value that you then want to extract the nibbles from? Do
you want the nibbles straight from the Unicode string that represents the
numbers? Do you want some other kind of string instead (e.g. ASCII)?

While you are thinking about those questions, you might review things like
the System.Text.Encoding class and its descendants, the Parse() method for
various numeric types, and the BitConverter class. Some or all of those
might be useful in solving your problem, depending on what your actual
goal is.

Pete
Jul 13 '07 #3

P: n/a

i just have to pass the result (the nibble) as string parameter to external
method in a external class.

could you please give an advice?

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,
"Ricardo Quintanilla" <Ri****************@discussions.microsoft.comwro te
in message news:9A**********************************@microsof t.com...
i need to convert data from string to nibble wich (nibble is a four bits
representation)

As example i have the following code

string data1 = "12345678";

so ┬┐how can i convert this data (numbers) to a nibble representation?

how do y ou want to keep the nibble? do u have a class for that?

You can convert it to int and extract the nibble of each digit
Jul 13 '07 #4

P: n/a
On Fri, 13 Jul 2007 07:18:01 -0700, Ricardo Quintanilla
<Ri****************@discussions.microsoft.comwrote :
i just have to pass the result (the nibble) as string parameter to
external
method in a external class.
A nibble isn't a string. It's 4 bits of data. So you have another
ambiguity in your question: you obviously want to convert the nibble back
to a string, so how exactly do you want to represent the nibble as a
string? What format should it have?
Jul 13 '07 #5

P: n/a
Thanks for your answer.

The numers that i have used for the example, will represent in my real code
a "credit card numer".

I need to implement some sort of special codificaction for a Visa process of
validation. It is an integration beetwen a visa partner and a bank in i work
for.

the requeriment was simpley: take the credit card numer, transform to a
nibble representation and pass that value to a method X.

thanks again
"Peter Duniho" wrote:
On Fri, 13 Jul 2007 06:52:01 -0700, Ricardo Quintanilla
<Ri****************@discussions.microsoft.comwrote :
i need to convert data from string to nibble wich (nibble is a four bits
representation)

As example i have the following code

string data1 = "12345678";

so ┬┐how can i convert this data (numbers) to a nibble representation?

Your question is too vague to be answered.

First, the question is when you write "this data (numbers)", what exactly
is the data you want to convert _from_? Do the numbers represent an
actual integer value that you then want to extract the nibbles from? Do
you want the nibbles straight from the Unicode string that represents the
numbers? Do you want some other kind of string instead (e.g. ASCII)?

While you are thinking about those questions, you might review things like
the System.Text.Encoding class and its descendants, the Parse() method for
various numeric types, and the BitConverter class. Some or all of those
might be useful in solving your problem, depending on what your actual
goal is.

Pete
Jul 13 '07 #6

P: n/a
On Jul 13, 3:32 pm, Ricardo Quintanilla
<RicardoQuintani...@discussions.microsoft.comwrote :
Thanks for your answer.

The numers that i have used for the example, will represent in my real code
a "credit card numer".

I need to implement some sort of special codificaction for a Visa process of
validation. It is an integration beetwen a visa partner and a bank in i work
for.

the requeriment was simpley: take the credit card numer, transform to a
nibble representation and pass that value to a method X.
That requirement is still too vague - it doesn't explain what a nibble
representation really is, or how the credit card number should be
transformed.

Given that this is a finance requirement, it's likely that there are
very detailed requirements *somewhere* - but you'll need to find them
before you can make any more progress.

Jon

Jul 13 '07 #7

P: n/a
Hi,

"Ricardo Quintanilla" <Ri****************@discussions.microsoft.comwro te
in message news:50**********************************@microsof t.com...
>
i just have to pass the result (the nibble) as string parameter to
external
method in a external class.
I do not understand, what do you want to see in the string? the 8 bit
representation of the 4 bit nibble?
Jul 13 '07 #8

P: n/a
On Fri, 13 Jul 2007 07:32:06 -0700, Ricardo Quintanilla
<Ri****************@discussions.microsoft.comwrote :
[...]
the requeriment was simpley: take the credit card numer, transform to a
nibble representation and pass that value to a method X.
As Jon points out, that's not a more specific explanation of what you need
to do. If anything, it creates new ambiguities, because it raises the
possibility that you are not in fact trying to get a "nibble" at all.

But regardless, without some precise statement of what the input and
output should be, it's not possible to answer the question.

Pete
Jul 13 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.