[Programming Fundamentals] 10.Data Overflow
Здравейте колеги . Искам да видя други решения на задачата "10.Data Overflow" :
Като моето решение има проблем ! Резултата е 80/100 , Благодаря предварително !
⦁ * Data Overflow
You will be given two numbers. Your task is to find the lowest one by value, find the numerical type it fits in from the following (byte, ushort, uint, ulong) and check how many times the greater one by value overflows the type of the smaller one (rounded to the nearest whole integer).
Input | Output | Explanation |
100000 5 |
bigger type: uint smaller type: byte 100000 can overflow byte 392 times |
uint.MinValue ≤ 100000 ≤ uint.MaxValue byte.MinValue ≤ 5 ≤ byte.MaxValue 100000 / byte.MaxValue = 392.1568 392 |
Input | Output | Input | Output | |
1200 2 |
bigger type: ushort smaller type: byte 1200 can overflow byte 5 times |
65535 131070 |
bigger type: uint smaller type: ushort 131070 can overflow ushort 2 times |
⦁ Rounding of the end result can be achieved by using the Math.Round() method.