bit-masking question

B

BigAias

Hi, I've been given a problem by my Comp Sci teacher over bit-masking,
which I have absolutely no knowledge about. I'm sure its going to be a
really simple and stupid question to a lot of folks out there, but its
not for me :)

Pretty much, I have to read in a character, then using a bitwise
operator, I have to determine whether it is uppercase or lowercase. If
its uppercase, I have to convert it to lowercase using bit-masking.

I know that the 5th bit is the one that determines uppercase or
lowercase and all that jazz, and I've been trying tons of things to
manipulate that, and nothing's working. Help, please :)
 
T

Thomas Weidenfeller

Hi, I've been given a problem by my Comp Sci teacher over bit-masking,
which I have absolutely no knowledge about. I'm sure its going to be a
really simple and stupid question to a lot of folks out there, but its
not for me :)

In general we don't do homework here. We don't want to deprive people of
their learning experience.

Patricia has some very good advice on how to tackle homework problems at:

http://home.earthlink.net/~patricia_shanahan/beginner.html

/Thomas
 
E

Eric Sosman

Hi, I've been given a problem by my Comp Sci teacher over bit-masking,
which I have absolutely no knowledge about. I'm sure its going to be a
really simple and stupid question to a lot of folks out there, but its
not for me :)

Pretty much, I have to read in a character, then using a bitwise
operator, I have to determine whether it is uppercase or lowercase. If
its uppercase, I have to convert it to lowercase using bit-masking.

I know that the 5th bit is the one that determines uppercase or
lowercase and all that jazz, and I've been trying tons of things to
manipulate that, and nothing's working. Help, please :)

IMHO your teacher has assigned a poor problem, unless
he or she has clearly explained that the problem is purely
an exercise in bit-bashing, and that no one in his right
mind would actually use bit-bashing to inspect or change the
case of a letter. For example, is 'ß' a letter? Of course:
you'll find it sprinkled throughout any German dictionary.
But is it an upper- or a lower-case letter? And what does
it look like when transformed to the other case?

Further: Once you've figured out the manipulation that
transforms 'a' to 'A', try the same trick on 'ð' and ponder
what you get. Once you've figured out a method that tells
you whether 'X' is upper- or lower-case, try your method
on '#' and on '3' and on '©' and justify the results.

Then contemplate why it just might be a teeny bit better
to stick with Character.isUpperCase() and the like instead
of trying to be too clever by half.

(Any bets on how long it will be before this teacher
tells BigAlias to write a bubble sort? ;-)
 
R

Roedy Green

Of course:
you'll find it sprinkled throughout any German dictionary.
But is it an upper- or a lower-case letter? And what does
it look like when transformed to the other case?

gruß:

The German ss Eszett or Scharfes S is a lower case letter, with no
upper case equivalent. The German government announced that you could
replace it with ss, but I am told there are words where it makes a
difference e.g. masse and maße.

see http://mindprod.com/jgloss/ligature.html
 
J

Joan

Roedy Green said:
gruß:

The German ss Eszett or Scharfes S is a lower case letter, with
no
upper case equivalent. The German government announced that you
could
replace it with ss, but I am told there are words where it
makes a
difference e.g. masse and maße.
The recent (couple years maybe) law in Germany is to not use ß
but to use ss. The young people have no trouble, but the older
ones
resist "the man".
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top