Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace dataOverflow
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal num1 = decimal.Parse(Console.ReadLine());
- decimal num2 = decimal.Parse(Console.ReadLine());
- int bytes = 255;
- int ushorts = 65535;
- uint ints = 4294967295;
- decimal overflow = 0;
- decimal big = Math.Max(num1, num2);
- decimal small=Math.Min(num1, num2);
- string bigger = (big <= ushorts? "bigger type: ushort" :
- big <= ints ? "bigger type: uint" : "bigger type: ulong");
- string smaller = (small <= bytes ? "smaller type: byte" : small <= ushorts ? "smaller type: ushort" :
- "smaller type: uint");
- Console.WriteLine(bigger);
- Console.WriteLine(smaller);
- if(small <= bytes)
- {
- overflow = big / bytes;
- Console.WriteLine($"{big} can overflow byte {Math.Round(overflow)} times");
- }
- else if( small <= ushorts)
- {
- overflow = big / ushorts;
- Console.WriteLine($"{big} can overflow ushort {Math.Round(overflow)} times");
- }
- else
- {
- overflow = big / ints;
- Console.WriteLine($"{big} can overflow uint {Math.Round(overflow)} times");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement