Question
Integer division in CO always rounds its result towards zero. In particular -9/2 is equal to -4. In other languages instead, the division always rounds
Integer division in CO always rounds its result towards zero. In particular -9/2 is equal to -4. In other languages instead, the division always rounds towards infinite. In this case, -9 divided by 2 is equal to -5. In this case the division is called the quotient and the associated modulus is called remainder. Let's suppose we want to implement this convention: you need to write two CO functions quotient and remainder with the following property: quotient(x,y)*y + remainder(x,y) == x; for all ints x and y unless quot overflows. Put the correspondig contracts in a file, and test them in Coin.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started