how to convert data from string to nibble

G

Guest

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Ricardo Quintanilla said:
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
 
G

Guest

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?
 
P

Peter Duniho

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
 
P

Peter Duniho

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?
 
G

Guest

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
 
J

Jon Skeet [C# MVP]

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Ricardo Quintanilla said:
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?
 
P

Peter Duniho

[...]
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
 

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

Similar Threads


Top