This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2022:projects:lmr1 [2022/10/20 19:02] – [OUTPUT SPECIFICATIONS] abarbcal | notes:discrete:fall2022:projects:lmr1 [2022/10/28 03:55] (current) – [OUTPUT SPECIFICATIONS] dmuck | ||
---|---|---|---|
Line 1: | Line 1: | ||
=====BACKGROUND===== | =====BACKGROUND===== | ||
+ | How do the math functions from the math.h library work? How can you add, subtract, divide, multiply, raise to a power, find a root, etc. without using binary operators? What is the logic behind your day-to-day mathematic operations? and how can you teach it to a computer? | ||
+ | |||
+ | Continuing from where we left off from lmr0, after making bitwise operator functions: | ||
+ | * Not | ||
+ | * And | ||
+ | * Nand | ||
+ | * Or | ||
+ | * Nor | ||
+ | * Xor | ||
+ | * Xnor | ||
+ | * Logical shift | ||
+ | * Logical rotate | ||
+ | |||
+ | This week we will be focusing on creating functions that do basic algorithm operations. | ||
=====SPECIFICATIONS===== | =====SPECIFICATIONS===== | ||
+ | Use your bitwise functions from lmr0. Bit arrays should be the output. | ||
+ | |||
*Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, | *Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, | ||
Line 7: | Line 23: | ||
*For anybody interested in editing the wiki page, here is the dokuwiki user guide: https:// | *For anybody interested in editing the wiki page, here is the dokuwiki user guide: https:// | ||
====OUTPUT SPECIFICATIONS==== | ====OUTPUT SPECIFICATIONS==== | ||
+ | Determine a unified means of output so that all submissions have an identical format. Should get identical output to running non-bitwise versions of the same functions. | ||
+ | Example: your function subtraction of 27 and 3 should output 24 just like 27 - 3 = 24. | ||
- | Determine a unified means of output so that all submissions have an identical format. | + | Make sure to be mindful |
=====PROGRAM===== | =====PROGRAM===== | ||
+ | Two main ways to approach this project: the more laid out approach, and the straight to the point approach. You can either do the bitwise portion of each mathematical operator and convert it to the bit array, or, just work with the bit array from the start. If you work with the bit array from the start, you might find some functions easier, but some functions could also be harder. There really isn't a " | ||
+ | When it comes to binary division and multiplication, | ||
=====EXAMPLES===== | =====EXAMPLES===== | ||
+ | ====COOL BITWISE TRICKS==== | ||
+ | 1. Right-shift is equivalent to dividing by 2\\ | ||
+ | 2. Left-shift is equivalent to multiplying by 2\\ | ||
+ | 3. AND can be used on the first bit to check for odd/even\\ | ||
=====VERIFICATION===== | =====VERIFICATION===== | ||
+ | Make sure to test multiple different numbers, some numbers may work while others may not. | ||
Derive a set of tests that all submissions should perform to ascertain correctness (state the tests, the inputs, and the expected outputs). In conjunction with conforming output specifications, | Derive a set of tests that all submissions should perform to ascertain correctness (state the tests, the inputs, and the expected outputs). In conjunction with conforming output specifications, | ||
Line 21: | Line 45: | ||
=====PSEUDOCODE===== | =====PSEUDOCODE===== | ||
+ | |||
+ | =====C++ operator overloading===== | ||
+ | C++ operator overloading could be relevant to this project as a means of cleaning up your code. With operator overloading you could go from | ||
+ | < | ||
+ | multiply(a, b) | ||
+ | </ | ||
+ | To: | ||
+ | < | ||
+ | a * b | ||
+ | </ | ||
+ | If you're interested in doing this the basic syntax is as follows: | ||
+ | < | ||
+ | struct MyStruct | ||
+ | { | ||
+ | MyStruct operator*(MyStruct other_struct) { ... } | ||
+ | bool operator==(int x) { ... } | ||
+ | } | ||
+ | </ | ||
+ | Its just a function with some nice syntax! | ||