DarkBASIC Programming/Number Crunching
Day 9 Cont'd
This lesson is all but one day long. When it's done, we'll move on to 2d don't expect mario or pong yet first thing we'll be doing is learning string manipulation, in about a day or so then we'll move on to images and whatnot. Who likes math? Not me, that's why we'll be getting DarkBASIC to do math for us. It'll be easier then using a calculator you won't even have to think about it.
Typical Math Operators
+ is Increment of a value = is equal to - is decrement of a value ÷ is the division symbol. (ALT + 246 to create the ASCII symbol for division) X multipying
Okay, first of all by increment I mean increasing a value by whatever and vice versia with decrement as you decrease values.
Typical Programming Operators
+ still addition = is equal to - is subtraction / is division * is Multiplication < is less than > is greater than <> is not equal to <= is less than or equal to >= is greater than or equal to := is assigned the value of...
Remember the above like you remember Christmas or you'll have problems doing math in programming! I can go on with more operators but it's not needed in a simple language like DarkBASIC as most of the math is taken care of by easier commands like wrapvalue.
This example may be easy but here it is
`Math Example `By Dbtutor a = 1+2 b = 3-7 c = 9/3 d = 10*2 Print a Print b Print c Print d wait key end
Most people have already known what was going to happen and what was going on.
Here's some easy stuff!
`Few math examples a = 67 hexofa$ = hex$(a) ` hex$ returns value of 'a' as a hexdecimal string. binaryofa$ = bin$(a) ` bin$ returns value of 'a' as a binary string. b = 3 c = sqr(b) inc d dec e Print a Print hexofa$ Print binaryofa$ Print b Print c Print d Print e wait key end
Why you'd need these above commands is beyond me, you only need them in rare situations, for more examples of math in DarkBASIC consult the DarkBASIC editor's command reference under math. For now it's over with...