Games
Problems
Go Pro!

Ask Professor Puzzler


Do you have a question you would like to ask Professor Puzzler? Click here to ask your question!
Category results for 'technology'.

"Sir , I saw your post about how to convert from alphabet to binary , in which I agree about the post. But there was a question I saw I'm my textbook which state that convert the hexadecimal number 4B3.3 to decimal. In your post here https://www.theproblemsite.com/ask/2016/01/converting-letters-to-binary, I notice that A= 65 and B =66. then I equate 66 to represent B. but after solving it there answer is different from mine .they got 1203.1875, and I got 18019.1875. How come sir? But I notice they equate there B = 11. Sir, I need your highlight on it. Thanks for talking time to read it, waiting for ur reply."


Hi Abolade, Thanks for asking this question. To understand the answer to that, I need to talk for just a moment about graphemes. A grapheme, according to one dictionary, is "The smallest meaningful contrastive unit in a writing system." That's a fancy way of saying that a grapheme is a symbol that represents something meaningful in a writing system. For example, "7" is a grapheme for the number seven. It's a symbol, and whenever you see it, you automatically know that it represents this many things:

X  X  X  X  X  X  X.

On the other hand, "72" is not a grapheme because it's not the smallest graphical unit. "72" is actually two graphemes: the grapheme for the number seven, and the grapheme for the number two.

Graphemes are also used to represent letters. "A" is the grapheme we use to represent the first vowel in the alphabet, "B" is the grapheme we use to represent the first consonant, and so forth. Of course, the graphemes for these letters might look different if you were writing a different language, such as Greek:  α β γ δ ε...

So here is where things get confusing. In base ten (our normal counting system), we have ten digits. And therefore, we have ten graphemes: 0 1 2 3 4 5 6 7 8 9. Perfect! We have just enough numerical graphemes! And if we're in base eight (also known as "octal"), we have eight graphemes: 0 1 2 3 4 5 6 7. We have more than enough graphemes (the graphemes for eight and nine don't get used in this base). 

In fact, for any base less than ten, we have more than enough graphemes. The problem is when we start talking about bases greater than ten. Then we don't have enough graphemes!

So instead of inventing new graphemes to represent these digits, mathematicians said, "Why waste the effort developing new symbols, when we've got all these other graphemes lying around not being used?" Specifically, we're talking about the alphabet graphemes. So if you are in base eleven, your graphemes are: 0 1 2 3 4 5 6 7 8 9 A, where A is the grapheme for the number ten.

Similarly, if you are in base sixteen (also known as "hexadecimal"), you have sixteen graphemes, and six of them are stolen from the alphabet: 0 1 2 3 4 5 6 7 8 9 A B C D E F.

It's very important to note that in this context, A, B, C, D, E, and F, even though they look like the graphemes for LETTERS, have a very different meaning; they are now graphemes for NUMBERS! 

A is the grapheme for the number ten
B is the grapheme for the number eleven
C is the grapheme for the number twelve
D is the grapheme for the number thirteen
E is the grapheme for the number fourteen
F is the grapheme for the number fifteen

The mathematicians very selfishly pirated letters from the alphabet to take on a completely different meaning. I mean, why not? It's not like there would be any confusion, right? Shakespeare was never going to write a sonnet about the hexadecimal number system, so there's no chance there would ever have an overlap of meaning where we were unsure whether A represents a number or a letter, right?

Wrong! Welcome to the world of computers! In a computer system, even though you can type graphemes and a computer can display graphemes, the computer does not understand graphemes. Computers "think" strictly in terms of numbers, not graphemes. Which means that people who designed computers had to come up with a system of converting graphemes into numbers, so the computer would be able to handle them.

How many graphemes are there? Well, don't forget that not only are there number graphemes and letter graphemes, there are also punctuation graphemes, mathematical operation graphemes, and special symbols like the pipe character, the tilde, etc.

So somewhere along the way, someone (or a committee of someones) had to develop a conversion chart so that whenever someone typed a character on the keyboard, there was a number that corresponded to whatever they typed. For example:

33 is the number that represents the exclamation mark grapheme
34 is the number that represents the quotation mark grapheme
43 is the number that represents the addition grapheme
65 is the number that represents the upper case "A" grapheme
66 is the number that represents the upper case "B" grapheme
97 is the number that represents the lower case "a" grapheme

Uh oh...now we have a problem! The grapheme "A" is a representation for the number 10, but 65 is the computer's value for the "A" grapheme. And this is the source of the confusion. Consider the following:

BAD = a hexadecimal number
BAD = of poor quality or low standard

Both of these statements are true. BAD is a hexadecimal number, but it's also a word! In one case, B, A, and D are graphemes for numbers, and in the other case, they are graphemes for letters! If you wanted to convert BAD (the number) into base ten, you would do this: 11 x 162 + 10 x 16 + 4 = 2980. But if you wanted to convert BAD (the text) into numbers, so the computer could deal with it, you would do this: B = 66, A = 65, D = 68.

So if you're dealing with numbers (as in your textbook), A = 10, B = 11, etc. If you're dealing with text (words), A = 65, B = 66, etc.

If only those lazy mathematicians had invented their own graphemes instead of just stealing from the alphabet, we wouldn't have this confusion!

Thanks for asking, and I hope there was something helpful to you in this lengthy explanation!

Professor Puzzler

Brock from Canada asks, "Computer programmers use hexadecimal code. I have read and learned your lesson on that but I cant figure out where to put and what the symbols mean when coding. these symbols are #,*,&. what do these symbols mean and where do I insert them when I am doing my programming?"

Hi Brock, thanks for your question. The answer is: it depends on the programming/scripting language you are using. Here are just a few examples. Note that in each example, the symbol (or symbols) that indicate a number is a hexadecimal value is shown in bold text.

If you were programming in the language C or C++, and you wanted to include a hexadecimal number in your program, it might look something like this:

int x = 0xFC;

If you were programming in Javascript your code would look the same.

If you were developing a website using HTML/CSS, and you wanted to provide a color as a hexadecimal value, it would look like this:

background-color:#FF0000;

This is equivalent to:

background-color:rgb(255,0,0);

If you were programming in PHP, you would also use 0x:

$x = 0xA3;

If you were programming in Visual Basic, you could write a hexadecimal number like this:

Dim x as Integer = &h2D

In Pascal (which I learned in college back in the 80s, but haven't used since), a hexadecimal value would be written with a dollar sign:

x := $B8;

Crystal, from Germany, asks: "A stranger sends an email with an attachment for a photo/file what do you do?"

Hi Crystal! Here's a short answer: Don't open any attachments from people you don't know. Now for the slightly longer answer...

There are certain types of files which are relatively safe to open, but even ones that you think would be safe might surprise you. Here's a Q&A that talks about one of those: File Attachments and Viruses. Even if you felt confident that a file type was safe to open, you need to be aware that people can be very sneaky. A file which is named "myimage.jpg?x=5.exe" might fool you into thinking it's a JPEG image file, but actually, because it has ".exe" on the end, it's an executable (program) file. You don't want to be opening that!

So if a complete stranger sends you some sort of attachment on an e-mail, you do one thing, and one thing only: you delete that email without opening the attachment. 

Unless...

Unless you work for a business where you might expect to receive e-mails from strangers. For example, suppose you work for a corporation in their personnel department. It's not unreasonable to suppose that you will get e-mails with resumes attached, from people who want to work for your company. I know this happens, because even though I've never advertised that I want to hire someone to work for me, I often get those kinds of e-mails.

So maybe they're legit. But maybe they're not. What to do?

Well, there are a few possibilities.

  1. Make sure you have the latest greatest virus software installed, cross your fingers, pray, and open that word processor document (Microsoft Word has a feature which causes documents from the internet to be opened in an uneditable "safe" mode, which makes it less likely that the file will give you problems, but I won't suggest that it decreases the probability to zero).
  2. Contact the person and tell them that you don't accept electronic resumes, and...
    1. Ask them to mail you a printed copy.
    2. Give them a fax number, and ask them to fax the document to you.
  3. Contact the person and ask them to put it into Google Docs, and share it with you.

Obviously, all but the first of these options result in hassle for everyone involved, so most people wil choose option 1. And under certain business circumstances it's impossible to avoid opening attachments from strangers. So if you're in a business situation where you have to open docs from strangers, make sure your virus software is up-to-date!

By the way, you can call me paranoid, but I'm even cautious about opening attachments from friends. After all, what if their computer is infected with a virus? Then their attached file could be infected as well, and they wouldn't even know it! It's like having chicken pox - you are contagious even before you know that you've been infected.

Kelly from the United States, has some questions that relate to our "Secret Messages and Codes" reference pages, about how different types of "things" get converted into hexadecimal and/or binary. This post will be an attempt to explore encoding a bit more.

Encoding Colors

In your computer's web browser, every color is made up of three numbers. Those three numbers are the red component of the color, the green component, and the blue component. Each of those numbers can range from 0 to 255, with 0 meaning, "Don't use this color," and 255 meaning "Give it all you've got of this color!" and all the numbers in between representating different gradations of that color.

So, for example, you could have a color represented like this: rgb(0,255,0), and that color would be green. You could represent another color like this: rgb(255,0,255). That color would be purple (full-blast red and blue, without any green). Or rgb(128,128,128). That color is equal amounts of all three components, which gives you gray.

rgb(255,255,255) is white, and rgb(0,0,0) is black.

However, that's not the only way to write colors for the computer to understand - you can take those three color components and write them in hexadecimal to tell the computer what the color is.

For example, if a website designer wanted to tell the browser to paint the screen dark purple, the designer could give the browser this number:

#440044

To see how this is purple, split it up into three 2-digit hexadecimal numbers:

#44, #00, #44

Since #44 = 68 (because #44 = 4 times sixteen, plus 4 more), and #00 = 0, this is identical to rgb(68,0,68).

Encoding Numbers

Encoding numbers - either into binary or hexadecimal - is done by the process outlined on our reference pages. It's a structured mathematical process by which we determine the largest power of the base (two or sixteen, for binary or hexadecimal respectively) and then work backwards to determine the digits of the number in a new base.

If I'm programming a computer, and I want the computer to multiply something by 51, my program includes the number 51, but the computer converts that to 110011binary before storing it, because the computer does all its calculations in binary, and all its memory storage is binary.

Encoding Graphemes

Do you know what a grapheme is? It is defined as follows: "A grapheme is the smallest unit used in describing the writing system of any given language." Graphemes are the symbols we use to represent meaning.

Graphemes include letters, numbers, and all our punctuation marks - basically, all the characters on your keyboard. Graphemes, like numbers, need to be converted into a numerical language the computer can understand if we want them to be stored in the computer. Technically, they are stored in binary, but we often use hexadecimal to represent graphemes.

But how in the world do you convert something like "&" to a number? There isn't a mathematical process you can use to do that, is there? No, there isn't. There's also no mathematical process for converting the letter "A" to hexadecimal. And, to make your head spin a little, there's also no mathematical process for converting "1" into hexadecimal.

Notice that I put the number "1" in quotes. Because it's not the number 1, it's the grapheme for the number 1.

So if there's no good mathematical method for doing this conversion, what do we do? We just create a table of values, and arbitrarily assign a number to each grapheme. For example,

"A" = 41
"B" = 42
"C" = 43
SPACE = 20
"1" = 31
"2" = 32
"&" = 26

Note that all of these are hexadecimal values. It may be strange to wrap your brain around the fact that "1" = 31. Mind you, I'm not saying 1 = 31. I'm saying "the grapheme for the number 1 has a value of 31 (hex)." If I tried to tell the computer that one equals 31, I think it would have a meltdown!

Incidentally, in computer programming, we don't call them "graphemes" - we call them "characters." And we don't limit ourselves to visible symbols; we also have character codes for things like the backspace key and the tab key, and the arrow keys.

Syntax Determines Encoding

Here's where we finally get around to answering Kelly's questions, which are along the lines of "If I enter 'PURPLE' in the hexadecimal encoder, why doesn't it give me the color values you describe? And If I enter the number 52 in the binary encoder, why doesn't it give me the value you say it will?"

And the answer is: Our encoder is an encoder for graphemes, rather than an encoder for colors and numbers.

So when you entered "PURPLE," you thought you were saying to the computer, "Show me the hexadecimal value for the color purple," but really you were saying, "Show me the hexadecimal values for the graphemes 'P', 'U', 'R', 'P', 'L', and 'E'."

Similarly, when you entered "52," you thought you were saying to the computer, 'Show me the binary value of the number 52, but really, you were saying, "Show me the binary values for the graphemes '5' and '2'."

The key is, we tell you "enter some text" - whenever we are entering "text," we are entering graphemes for the computer to deal with.

In computer programming, and in web design, we have to be able to specify how we want to have the computer interpret the content we provide - whether we want the computer to interpret as colors, as numbers, or as text. This is why programming languages have syntax, or programming "grammar" - the grammar of a programming language helps the computer determine how we want to have things understood.

It's just like English grammar, in a way. Consider the word "content" used in the paragraph above. "Content" can be either a noun or an adjective ("I added content to the page," vs. "I am content with this page."). But when you read the sentence above, you probably didn't even hesitate to understand how I intended you to interpret the word "content." Why? Because the structure/grammar/syntax of the sentence made it clear how the word was to be interpreted.

In the same way, in the world of computer programming and web design, we use syntax to indicate how we want information to be interpreted. One of the simplest rules is: If we put it in quotes, we want it interpreted as graphemes.  Of course, nothing can be that simple. A quotation mark is a grapheme, so what if you want a quotation mark inside the text? How does the computer know whether to interpret that quotation mark as the end of the text, or as part of the text? The rules can get messy!

So for our encoder, since we've said, "enter some text," your entire entry in the textbox is treated as content to be interpreted as graphemes.

I hope that lengthy explanation added some clarity for you! Thanks for asking.

Here's another blog post that explores encoding some more: Letter codes and binary.

I am Ben and I am in forth grade. I would like to know what a trojan horse is.


 

Well Ben, I notice that you said "a trojan horse," rather than "the trojan horse." That does make a difference in the explanation. First I'll review (in case you didn't know) what the trojan horse was, then we'll talk about how that phrase is used today in the world of computers.

Did you ever learn about the Trojan War? The Trojans were citizens of the city of Troy. The story of their war with the Greeks is recounted in Homer's Iliad, and other Greek literature. According to the story, the Trojans defended their city against the Greeks, but they finally lost when their enemies built an enormous wooden horse and hid a group of soldiers inside it. The Trojans thought it was a peace offering, so they brought it into the city and had a big party.

Then, in the middle of the night, while everyone was asleep, the soldiers climbed out of the horse and opened the city gates, letting in the Greek army. The Trojans were defeated because they were so gullible.

That's the trojan horse. But today we use that phrase to mean something similar, but different.

In computer terms, a Trojan Horse is a computer virus that is designed to fool people, just like the Trojans were fooled. It may be a program that is supposed to do something helpful, but really is also doing some unhelpful things.

Maybe you get an email that says "The attached file is an update from Microsoft. Open it to update your computer." Only, it's not really an update from Microsoft - it's a program that deletes all the files on your computer. But you believe the message, so you open the file. Now you're just like the Trojans. You thought you had something nice, but it turns out to be very nasty instead.That's a Trojan Horse.

Or you might be looking for a piece of software to do a particular job. Maybe you want some photo editing software, or screen capture software, or video conversion software. So you go looking online, and you find a free version of the software. You get excited about not having to pay anything, and you download it. But you don't realize that the software is actually spying on you, or damaging your computer in some way.

And by the way, that should be a good reminder to you of how cautious you should be when you download files from the internet, and when you open files attached to e-mails. Don't be like the Trojans - always be suspicious!

Older posts

Featured Resources on This Site

Create Christmas ornaments and more
Print fun mazes in many different shapes

Blogs on This Site

Reviews and book lists - books we love!
The site administrator fields questions from visitors.
Like us on Facebook to get updates about new resources
Home
Pro Membership
About
Privacy