Pages: [1]   Go Down
Author Topic: Programming with Variables.  (Read 248 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
Karma: 29
Posts: 2362
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I never studied Algebra, never took an interest in Maths in school, I was more about Science and hands on hardware, but i've just been accepted to enroll at my school and they're
going to be testing my maths skills - eek, so I thought i'd quickly brush up on the basics of Algebra just incase i get asked about it.

So I find the video... basics on Algebra

X + 4 = 12

So this is the first example i'm confronted with... um i'm taken back what's the value of x?  Surely the compiler will know that
at compile time, who cares!

Then i thought, if i saw that in Code, how would i normally work that out? i'd go x = 12 - 4 (x must be 8 then)

he comes up with

x + 4 = 12
x + 4 - 4 = 12 - 4
x = 8

As far as i'm concerned, if i coded like this with a Micro controller i'm going to run out of variables fast so the question
how does Algebra affect the programming world, as coders are we already not doing a subtle form Algebra anyway? every
time i code a routine which involves numbers, is that not Algebra? i'm confused what's the relationship between coding
what's it mostly represent in the mathematics world?  because as far as I'm concerned, that guy's a moron, X is a variable
so what is x REALLY?

is it an Integer? Float? see my point, maybe Algebra is simply a memory consuming monster Variant and X, Y can be what
they want... int x,y,z; x = 10;  x = x * 10;    what's in X? again THE COMPILE DOES! but, X is 10 before it executes
the line x = x * 10; now it's 100, in X, but as a programmer, this comes naturally to me to determine the value of a given
variable well i Lie, i don't the compiler does lol... but I'd work it out through logic, can I not apply this to pure Algebra?

SF Bay Area (USA)
Online Online
Tesla Member
Karma: 124
Posts: 6652
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Compiler expressions are not algebra.  "X+4 = 12" would not compile in any language I'm aware of, and "X = X+1" makes no sense algebraically.  Various computer languages over time have attempted to abolish "=" as an assignment operator, because of this very issue.
Likewise, a "variable" means different things in a programming world (where it represents storage) and algebra (where it represents an unknown quantity.)
Algebra pretty much defines the rules that let you re-arrange and solve equations.  If you've never been exposed to algebra formally (sheesh; we started "some" back in 6th grade), you might find it enlightening. But DON'T try to make every bit of algebra map onto some coding construct...

Pages: [1]   Go Up
Jump to: