Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,147,902 members, 7,799,026 topics. Date: Tuesday, 16 April 2024 at 02:05 PM

How Is The Code For A Calculator (hardware), Written Into It. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How Is The Code For A Calculator (hardware), Written Into It. (5160 Views)

How To Code A Calculator Using Php / How To Make A Simple Calculator In Notepad Using .bat Format / How To Create A Simple Calculator Using Java Programing Language GUI (2) (3) (4)

(1) (2) (Reply) (Go Down)

How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 7:51am On Sep 29, 2013
Hello guys good morning.
I'm learning programming and hope to be a master of the art one day, and probably the G.O.A.T too. grin. So I'm curious and try to learn a lot.
As a personal project, I designed a simple calculator with vb.net and python. Nothing fancy just a calculator with simple functions like the Jamb version. When through, i sat back admiring my work and suddenly heard a loud sound "clack" and the JAMB calculator i was using as the basis for my calculator design dropped to the floor from the table and scattered irrevocably. To my surprise, (anyway i don't know what i was expecting) i saw that what was inside the calculator was just a transparent sheet with some black lines on it and a kind of material which is used to press down on the sheet. Since the buttons were scattered, i saw that using just the material to press down on the sheet, i could Still operate the calculator comfortably(only ish is that the signs aren't written on it).
Intuitively, i knew that the code for the calculator is written into that sheet with the black lines on it; but how? Because all i see are just black lines. So please those of you who are already pros should explain this to me, knowledge of this can improve my proficiency. i tried Google, but didn't know the proper search words to use.
Thanks

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 8:53am On Sep 29, 2013
It is called 'embedded programming'

4 Likes

Re: How Is The Code For A Calculator (hardware), Written Into It. by k0d3ch1k(f): 11:57pm On Oct 02, 2013
pls anymore info on dis? am also interested

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 10:23am On Oct 03, 2013
Lol. There is NO code if it is a simple calculator. Simple logic gates/circuits are all it takes to implement trivial functions like basic math operations (addition, subtraction, multiplication and division).
Re: How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 10:37am On Oct 03, 2013
logica: Lol. There is NO code if it is a simple calculator. Simple logic gates/circuits are all it takes to implement trivial functions like basic math operations (addition, subtraction, multiplication and division).
please sir kindly explain more, i ain't getting the gist.
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 11:22am On Oct 03, 2013
Artorius:
please sir kindly explain more, i ain't getting the gist.
I am taking you to the basics of computing: logic gates and circuits. Binary, 1s and 0s. OFF and ON. The fact is logic circuits are the foundation of computing. And any program you can think of writing can be implemented in ALL hardware as logic circuits though this could be quite complex and almost impossible to achieve. Software came about as a result of the inflexibility and complexity of logic circuits. If you need to know more about logic circuits, I suggest you get on Google as I cannot give a comprehensive treatise here.

2 Likes

Re: How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 2:35pm On Oct 03, 2013
logica: I am taking you to the basics of computing: logic gates and circuits. Binary, 1s and 0s. OFF and ON. The fact is logic circuits are the foundation of computing. And any program you can think of writing can be implemented in ALL hardware as logic circuits though this could be quite complex and almost impossible to achieve. Software came about as a result of the inflexibility and complexity of logic circuits. If you need to know more about logic circuits, I suggest you get on Google as I cannot give a comprehensive treatise here.
thanks. I appreciate
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 7:46am On Oct 04, 2013
Artorius:
Intuitively, i knew that the code for the calculator is written into that sheet with the black lines on it; but how? Because all i see are just black lines.

Correction [s]To do this a code like C is embedded into that sheet[/s]. For how the hardware works then we are going into electronics i.e. logic gates and these are used by the logical operator of your code i.e. &&, OR, || etc hope this helps.
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 9:25am On Oct 04, 2013
csharpjava:

To do this a code like C is embedded into that sheet. For how the hardware works then we are going into electronics i.e. logic gates and these are used by the logical operator of your code i.e. &&, OR, || etc hope this helps.
Dude, there is no code. The first thing you learn as a computer science major is a basic calculator is not a computer. It is just an electronic device. Don't confuse the novice please.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 11:35am On Oct 04, 2013
Like @Logica said, there is no code if it is a simple specialized calculator that implements a few operations.
Basically, anything that can be written as software can be implemented as hardware. Anything at all. The basic components of any hardware are transistors. They make up VLSI systems. And they are the basis for logic gates and memory.
Hardware implementations of systems are in orders of magnitude faster than software implementations. But software implementations are generally more flexible and allow for easy upgrade and change without much change to the hardware itself.
But in some other calculators that implement higher calculations and function, the code maybe written in assembly language and downloaded into the chip before the chip is fused with the system.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 11:56am On Oct 04, 2013
Thanks a lot phenomenon and logica, i really appreciate you taking your time here. Thanks to csharpjava for his contribution.
Peace
Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 2:43pm On Oct 04, 2013
Seems I have time a little so let me make things a little clearer here.
A logic circuit is a connection of transistors in such a way that produces some set of desired outputs. If u ever did symbolic logic in school, it would be easier to understand digital logic.
Since digital electronics only allow for two states, ON and OFF, the states are usually represented by 1 and 0 respectively. Ur computer only understands binary maths.
There are different logic gates which include AND gates, OR gates, XAND, XOR, NAND, and NOR.
NAND and NOR are the most commonly used as any of the others can be implemented as a several combination of one of them.
........to be continued.
Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 3:07pm On Oct 04, 2013
Now, ur calculator is just a simple computer. Any computer consists mainly of Arithmetic Logic unit (ALU), decoders/encoders converters, shift registers and others.
For simplicity sake, I will assume we are dealing with a 4-bit system. (I am sure u have heard of 32- or 64-bits systems)
Decoders are logic devices that convert ur inputs into the desired output form. A good example in ur calculator will be one that converts the number u press on the calculator to the true binary value of that number. Let's assume there are 12 buttons on the calculator, 0-9, +,-. Now without pressing them what the processor will be seeing at its input is "0000000000".
By pressing one of them, say, the key 3, they are changed to "0001000000" for example. The decoder will be useful in converting this 12-bit number to the 4-bit binary representation of 3 which is "0011". Same goes for any other button.
The binary form can then be stored in a shift register. And then the next number is also collected and stored and so on.
......to be continued.
Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 3:42pm On Oct 04, 2013
NOTE: all the computations done by a computer is just addition. Subtraction, multiplications and divisions are just special forms of addition. Even those fansy functions we implement (e.g. Fast Fourier Transforms, Taylor series and Newton's method; which most advanced calculators use in computing sine and cosine functions) are still reduced to additions in the processor.

The ALU is just another logic device that does computations on values stored in the previous steps based on the values of the operands and the operator.
Subtraction of a number B from another number A, that is A-B, is done by adding inverting B and adding "1" to it then adding the result to A.
Let's say A= 4 = "0100";
and B= 3= "0011"
then A-B is computed by A+B'+1
where B' is B inverted.
Then A-B is:
0100
+1100
+ 1
=0001
And "0001" is the binary for 1.
Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 3:54pm On Oct 04, 2013
I have a simple calculator hardware I implemented sometime back using NAND logic gates only and I simulated it on a software simulator. I will have to go look for it where I left it. This thread brings memories. smiley smiley
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 7:46pm On Oct 04, 2013
PhenomenonVFX: NOTE: all the computations done by a computer is just addition. Subtraction, multiplications and divisions are just special forms of addition. Even those fansy functions we implement (e.g. Fast Fourier Transforms, Taylor series and Newton's method; which most advanced calculators use in computing sine and cosine functions) are still reduced to additions in the processor.

A computer uses logic gates for doing computations. Here is a passage from a book:

5.11. Logic Gates
The information is represented in the computer in binary form. Binary information is represented using signals in two states off or on which correspond to 0 or 1, respectively. The manipulation of the binary information is done using logic gates. Logic gates are the hardware electronic circuits which operate on the input signals to produce the output signals. Each logic gate has a unique symbol and its operation is described using algebraic expression. For each gate, the truth table shows the output that will be outputted for the different possible combinations of the input signal. The AND, OR and NOT are the basic logic gates. Some of the basic combination of gates that are widely used are—NAND, NOR, XOR and XNOR. http://my.safaribooksonline.com/book/information-technology-and-software-development/9788131733097/data-representation/ch05lev1sec11#X2ludGVybmFsX0h0bWxWaWV3P3htbGlkPTk3ODgxMzE3MzMwOTclMkZjaDA1bGV2MXNlYzExJnF1ZXJ5PQ==
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 8:01pm On Oct 04, 2013
logica: Dude, there is no code. The first thing you learn as a computer science major is a basic calculator is not a computer. It is just an electronic device. Don't confuse the novice please.

Read this to know that calculators have codes in them:
Correction
Today, in addition to modern versions of the basic pocket calculator, complex scientific and graphing calculators are available and used by both students and professionals such as engineers. Many use well-known computer languages and are programmable according to the user's needs. http://electronics.howstuffworks.com/gadgets/other-gadgets/calculator1.htm
Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 9:08pm On Oct 04, 2013
^^SMH at this guy. What has what u just posted got to do with @logica's post that u quoted.
OP just take @logica's last explanation. And read up more if u may.
It is good u have zeal to know how things tick.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 9:12pm On Oct 04, 2013
PhenomenonVFX: ^^SMH at this guy. What has what u just posted got to do with @logica's post that u quoted.

I've had to make a correction to my earlier post.
csharpjava:

Read this to know that calculators have codes in them:
Correction
Today, in addition to modern versions of the basic pocket calculator, complex scientific and graphing calculators are available and used by both students and professionals such as engineers. Many use well-known computer languages and are programmable according to the user's needs. http://electronics.howstuffworks.com/gadgets/other-gadgets/calculator1.htm
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 10:21pm On Oct 04, 2013
csharpjava:

Read this to know that calculators have codes in them:
Correction
Today, in addition to modern versions of the basic pocket calculator, complex scientific and graphing calculators are available and used by both students and professionals such as engineers. Many use well-known computer languages and are programmable according to the user's needs. http://electronics.howstuffworks.com/gadgets/other-gadgets/calculator1.htm
And is the JAMB calculator a scientific calculator or graphing calculator? Do you know how to read?
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 10:36pm On Oct 04, 2013
logica: And is the JAMB calculator a scientific calculator or graphing calculator?

How come you can't see this: basic pocket calculator above. Stop trying to have the last say in something you know nothing about.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 10:56pm On Oct 04, 2013
Internal workings of a basic electronic calculator http://en.wikipedia.org/wiki/Calculator

In general, a basic electronic calculator consists of the following components:
Power source (battery or solar cell)
Keypad - consists of keys used to input numbers and function commands (addition, multiplication, square-root, etc.)
Processor chip (microprocessor) contains:
Scanning unit - when a calculator is powered on, it scans the keypad waiting to pick up an electrical signal when a key is pressed.
Encoder unit - converts the numbers and functions into binary code.
X register and Y register - They are number stores where numbers are stored temporarily while doing calculations. All numbers go into the X register first. The number in the X register is shown on the display.
Flag register - The function for the calculation is stored here until the calculator needs it.
Permanent memory (ROM) - The instructions for in-built functions (arithmetic operations, square roots, percentages, trigonometry etc.) are stored here in binary form. These instructions are "programs" stored permanently and cannot be erased.
User memory (RAM) - The store where numbers can be stored by the user. User memory contents can be changed or erased by the user.
Arithmetic logic unit (ALU) - The ALU executes all arithmetic and logic instructions, and provides the results in binary coded form.
Decoder unit - converts binary code into "decimal" numbers which can be displayed on the display unit.
Display panel - displays input numbers, commands and results. Seven stripes (segments) are used to represent each digit in a basic calculator.
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 12:35am On Oct 05, 2013
csharpjava:

How come you can't see this: basic pocket calculator above. Stop trying to have the last say in something you know nothing about.
LMAO. I'll just ask, what university did you finish from?
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 12:41am On Oct 05, 2013
csharpjava:

To do this a code like C is embedded into that sheet.
LMAO
Re: How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 12:53am On Oct 05, 2013
Thanks guys, special thanks to phenomenon (my man you really made my day ) thanks also to csharpjava for those links, they were very educative. Thanks also to logica.
Will i be asking for too much if i ask you guys to drop your numbers in case i need further explanations on related issues?
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 6:30am On Oct 05, 2013
logica: LMAO. I'll just ask, what university did you finish from?

Just accept it, that I have proved you wrong, so go back and tell whoever taught you in computer science major that a basic calculator has a program stored in it.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by Nobody: 6:33am On Oct 05, 2013
@logica just ignore that dude. I have been trying to educate him in one of his threads that he opened on game engine development. The guy isnt just ready to learn.
All he does is spout drivel with criminal ignorance. And then he copies and pastes a lot of text that doesnt in any way help his cause.
He seems ready to confuse other people who genuinely seek knowledge.

OP, I think it will be better if u bring any of the problems u have here so people can collectively tackle it for u here. That way other people can learn from it too. And even the people who are teaching u can be corrected by other people in case of errors. That is d way I see it.
Re: How Is The Code For A Calculator (hardware), Written Into It. by Artorius(m): 7:11am On Oct 05, 2013
PhenomenonVFX: @logica just ignore that dude. I have been trying to educate him in one of his threads that he opened on game engine development. The guy isnt just ready to learn.
All he does is spout drivel with criminal ignorance. And then he copies and pastes a lot of text that doesnt in any way help his cause.
He seems ready to confuse other people who genuinely seek knowledge.

OP, I think it will be better if u bring any of the problems u have here so people can collectively tackle it for u here. That way other people can learn from it too. And even the people who are teaching u can be corrected by other people in case of errors. That is d way I see it.
i can't disagree
Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 7:21am On Oct 05, 2013
PhenomenonVFX: @logica just ignore that dude. I have been trying to educate him in one of his threads that he opened on game engine development. The guy isnt just ready to learn.
All he does is spout drivel with criminal ignorance. And then he copies and pastes a lot of text that doesnt in any way help his cause.
He seems ready to confuse other people who genuinely seek knowledge.

But why all these abuse over a question I have answered with proofs from the website of wikipedia http://en.wikipedia.org/wiki/Calculator howstuffworks and from an online book.

What Journals or books have you written to show that you are an expert in this field. You guys still have a along way to go.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 11:56am On Oct 05, 2013
csharpjava:

But why all these abuse over a question I have answered with proofs from the website of wikipedia http://en.wikipedia.org/wiki/Calculator howstuffworks and from an online book.

What Journals or books have you written to show that you are an expert in this field. You guys still have a along way to go.
I, like PhenomenonVX spent many hours designing and implementing logic circuits at the university and the most trivial of them was a basic calculator.

The reason I asked what university you went to was because I was sure you didn't go to any. Or you did not study computer engineering which would mean you lack proficiency on this matter and you shouldn't be feeling among.

Here is another of your posts that show your ignorance:
"To do this a code like C is embedded into that sheet."
What silliness! How can you even embed code into a printed circuit? If there is any code anywhere, then it would be in an IC (integrated circuit) and not on the sheet.

Lastly, even the Wikipedia page you quoted has the layout of a basic pocket calculator (without functions). Once you have functions, the calculator is no longer "basic". If you studied Computer Science, you would have been told that a computer is made up of input, output and processing units. And what differentiates a calculator from a computer is the absence of a processing unit in the former. And the only way a computer can run a program is using its processor. Meaning if a device does not have a processor, it cannot run programs. Once an electronic device had a processing unit, it has graduated to a computer.

End of CSC203.

1 Like

Re: How Is The Code For A Calculator (hardware), Written Into It. by csharpjava(m): 12:43pm On Oct 05, 2013
logica:
Lastly, even the Wikipedia page you quoted has the layout of a basic pocket calculator (without functions). Once you have functions, the calculator is no longer "basic".

Can't you see the word basic below. For you information, information technology on Wikipedia is correct and upto date

In general, a basic electronic calculator consists of the following components:
Power source (battery or solar cell)
Keypad - consists of keys used to input numbers and function commands (addition, multiplication, square-root, etc.)
Processor chip (microprocessor) contains:
Scanning unit - when a calculator is powered on, it scans the keypad waiting to pick up an electrical signal when a key is pressed.
Encoder unit - converts the numbers and functions into binary code.
X register and Y register - They are number stores where numbers are stored temporarily while doing calculations. All numbers go into the X register first. The number in the X register is shown on the display.
Flag register - The function for the calculation is stored here until the calculator needs it.
Permanent memory (ROM) - The instructions for in-built functions (arithmetic operations, square roots, percentages, trigonometry etc.) are stored here in binary form. These instructions are "programs" stored permanently and cannot be erased.
User memory (RAM) - The store where numbers can be stored by the user. User memory contents can be changed or erased by the user.
Arithmetic logic unit (ALU) - The ALU executes all arithmetic and logic instructions, and provides the results in binary coded form.
Decoder unit - converts binary code into "decimal" numbers which can be displayed on the display unit.
Display panel - displays input numbers, commands and results. Seven stripes (segments) are used to represent each digit in a basic calculator.
http://en.wikipedia.org/wiki/Calculator
Re: How Is The Code For A Calculator (hardware), Written Into It. by logica(m): 12:47pm On Oct 05, 2013
csharpjava:

Can't you see the word basic below. For you information, information technology on Wikipedia is correct and upto date

In general, a basic electronic calculator consists of the following components:
Power source (battery or solar cell)
Keypad - consists of keys used to input numbers and function commands (addition, multiplication, square-root, etc.)
Processor chip (microprocessor) contains:
Scanning unit - when a calculator is powered on, it scans the keypad waiting to pick up an electrical signal when a key is pressed.
Encoder unit - converts the numbers and functions into binary code.
X register and Y register - They are number stores where numbers are stored temporarily while doing calculations. All numbers go into the X register first. The number in the X register is shown on the display.
Flag register - The function for the calculation is stored here until the calculator needs it.
Permanent memory (ROM) - The instructions for in-built functions (arithmetic operations, square roots, percentages, trigonometry etc.) are stored here in binary form. These instructions are "programs" stored permanently and cannot be erased.
User memory (RAM) - The store where numbers can be stored by the user. User memory contents can be changed or erased by the user.
Arithmetic logic unit (ALU) - The ALU executes all arithmetic and logic instructions, and provides the results in binary coded form.
Decoder unit - converts binary code into "decimal" numbers which can be displayed on the display unit.
Display panel - displays input numbers, commands and results. Seven stripes (segments) are used to represent each digit in a basic calculator.

From same Wikipedia:

Basic pocket calculator layout
MC M+ M- MR
C ± ÷ ×
7 8 9 -
4 5 6 +
1 2 3 =
0 .
MC Memory Clear
M+ Memory Addition
M- Memory Subtraction
MR Memory Recall
C Clear display (last entered number, whereas CE: Clear everything, start all over again)
± Toggle positive/negative number
÷ Division
× Multiplication
- Subtraction
+ Addition
. Decimal point
= Result

So which is which? Only those who then went to a proper university can tell which is which. So which university did you graduate from? And what was your major?

(1) (2) (Reply)

Do you Need A Very Cheap Hosting For A Small Web Project? Just 2k / How Do I Improve My Programming Skills? / Free Csharp, Mvc, Jquery And More Tutorials Online

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 73
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.