Write a function that returns the value of a number divided by 2
(Positive)(Truncated)
div2(7) = 3
div2(10) = 5
unsigned long long div2(unsigned long long a){
//Use binary operators...I-O
return a >> 1;
}
// TODO: Replace examples and use TDD by writing your own tests
Describe(d2)
{
It(under10)
{
Assert::That(div2(10), Equals(5));
Assert::That(div2(0), Equals(0));
Assert::That(div2(3), Equals(1));
}
It(huge_numbers)
{
Assert::That(div2(65536), Equals(32768));
Assert::That(div2(6553665535), Equals(3276832767));
Assert::That(div2(1234567890), Equals(617283945));
}
};