FAQ Database Discussion Community

Sort function giving floating point exception for a large input of 0's

I have written a code for this problem: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return...

_controlfp does not prevent DivideByZeroException

I wrote the following lines in C# using System; using System.Runtime.InteropServices; namespace ConsoleApplication1 { class Program { [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] extern static uint _controlfp(uint newcw, uint mask); const uint _MCW_EM = 0x0008001f; public const uint EM_INVALID = 0x00000010; public const uint EM_DENORMAL = 0x00080000; public const uint EM_ZERODIVIDE =...

Floating Point Exception in C++?

I'm writing a simple program that does int division and shows the remainder. I am trying to have the program run continuously until the user inputs 0 0. The program does stop after the user puts 0 0 but not before it says "Floating point exception" every single time. This...