jorritolthuis / integer-arithmetic Goto Github PK
View Code? Open in Web Editor NEWFirst integer arithmetic assignment for the TU/e course 2WF90
Home Page: https://www.overleaf.com/read/wdcwvjhdgjjy
First integer arithmetic assignment for the TU/e course 2WF90
Home Page: https://www.overleaf.com/read/wdcwvjhdgjjy
Currently it only possible to have a carry of 1. In theory we could have D+E (hexadecimal) as input. This would convert to 13+14 = 27 (carry of 2). Hence, our result will be 11 whereas the answer should be 1B.
The output of multiply, add and subtract are correct. This means there must be a mistake in the method of Karatsuba itself.
When substracting numbers and the answer should get negative; it does return a bullshit answer.
Input:
[radix] 10
[subtract]
[x] 2300
[y] 4100
# [answer] -1800
Output:
# [x] 2300
# [subtract] with radix 10
# [y] 4100
# [result] 18200
When giving multiple inputs to Add, a NullPointerException is triggered at the first if-statement (i.e. x or y seems null).
I am not sure if this is caused by commit b16e1fe.
The Add class can use some more comments, to me it's not clear what happens.
Add some comments to improve readability of code as requested by the assignment.
Copying remaining part goes wrong on two part:
if there isn't a carry or when there is a carry but next number is the highest number in the base
When running Karatsuba, there is an instance at which it needs to add 1000
and -00100
in radix 2. It calls subtract after which an error is thrown.
Edit: The line numbers of Karatsuba might have shifted
Input: (or just giving -f ./test/example.txt as argument when running)
[radix] 2
[karatsuba]
[x] 1111001110011011011101001100010101111000011010100100001101011101111101101110010001111010001010110011
[y] 1110110000001110100000101100010100101010110001101100011011101000101001001001000100001111010100100110
# [answer] 11100000101000010001111010010110111111100111000001010111101100100100001100000010011011111001001001111100000010010100100011101011001011000101101001100010110001000001001000100011100001110111010110010010
Directly giving the following input as command also results in the same error: (is the reduced version of the problem)
[radix] 2
[add]
[x] 1000
[y] -00100
end
example.txt shows that it is possible to have multiple inputs in one file. How are we going to handle that?
example.txt
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.