Char representation in byte

P

Peter Krikelis

Hi,

I have a problem converting chars that are represented in
more then 7F(in hex). I need to convert char to byte.
When I cast chars into bytes it is no problem when chars
are <= 7F(in hex), however when I do same thing to for
example char (%divided by infinity which is 89(in hex) it
gives me error out of bound. because it somehow converts
it into the decimal 8240 which requires 2 bytes.

Please, any help would be appresiated.

Pete.
 
J

Jon Skeet [C# MVP]

Peter Krikelis said:
I have a problem converting chars that are represented in
more then 7F(in hex). I need to convert char to byte.

That's going to be tricky given that chars in .NET are 16 bit entities
and bytes are only 8 bit entities.
When I cast chars into bytes it is no problem when chars
are <= 7F(in hex), however when I do same thing to for
example char (%divided by infinity which is 89(in hex) it
gives me error out of bound. because it somehow converts
it into the decimal 8240 which requires 2 bytes.

I think you actually mean Unicode 8240, (0x2030). In what way is that
89 in hex?

(It's not actually % divided by infinity, it's % with an extra ring at
the bottom, but I don't think it can be coincidence that it sounds so
like what you're talking about.)

See http://www.pobox.com/~skeet/csharp/unicode.html for more info.
 
J

Jeroen Smits

(It's not actually % divided by infinity, it's % with an extra ring at
the bottom, but I don't think it can be coincidence that it sounds so
like what you're talking about.)

It's called the per-mille sign.

% - per cent i.e. per hundrend
%o - per mille => per thousand

0.1 percent = 1 permille
 

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

Top