The exception that is thrown when an arithmetic, casting, or conversion operation in a checked context results in an overflow.
Questions tagged [overflowexception]
78 questions
3
votes
1 answer
Where to put an arithmetic checked statement?
I'm reading about how to force an operation to throw an overflow exception, and on the "try it yourself" section, I had it in a different place than the book. I'm curious if there's a performance issue associated with one spot or the other, as I'm…

krillgar
- 12,596
- 6
- 50
- 86
3
votes
2 answers
Microsoft chart control - redraw chart after failure (red cross)
I have a treeView element where every node represent a double list.
I'm using a DataVisualization.Charting control to display the values in the list.
For some of the lists I get an exception after RecalculateAxesScale (System.OverflowException:…

purbsel
- 307
- 8
- 21
3
votes
1 answer
array creation expressions and long dimension lengths
I was just reading the C# specification and the part on array creation expressions. In the specification it says:
array-creation-expression:
new non-array-type [ expression-list ] rank-specifiersopt array-initializeropt
new array-type …

Mishax
- 4,442
- 5
- 39
- 63
2
votes
2 answers
Value was either too large or too small for an Int16 ,when copy to data table
Q:
The following code:
var dtInstTotal = dtExternal.AsEnumerable()
.Union(dtEmployed.AsEnumerable())
.OrderBy(d => d.Field("emp_name"));
dtInst =…

Anyname Donotcare
- 11,113
- 66
- 219
- 392
2
votes
1 answer
Why can OverflowExceptions happen for decimal->byte conversions but not for uint->byte?
I'm wondering if anyone can explain an OverflowException I am seeing.
Consider the following code:
uint fred = 32768;
byte wilma = (byte)fred;
decimal bamBam = fred;
wilma = (byte)bamBam;
I only get an…

John Chenault
- 141
- 6
2
votes
5 answers
recursive stack size?
class Program
{
static void Main(string[] args)
{
Test(0);
}
static void Test(int i)
{
if (i > 30000)
{
return;
}
Test(i + 1);
}
}
Why getting recursive function and…

shenhengbin
- 4,236
- 1
- 24
- 33
2
votes
3 answers
Decimal parse of exponential 0 value (0+E3)
Our middle tier sends us serialized objects and sometimes a 0, due to some math operations in java on the server, come through as 0E+3. When deserializing the object we get an XmlException --> System.OverflowException because the value is too large…

Ben
- 597
- 1
- 6
- 19
2
votes
1 answer
VB.NET OverflowException on very small operation
I'm trying to merge 2 colors and to do so I created a very simple function:
Public Function MixColors(color1 As Color, color2 As Color) As Color
Dim a, r, g, b As Byte
a = (color1.A + color2.A) \ 2
r = (color1.R + color2.R) \ 2
g =…

des
- 67
- 1
- 8
2
votes
1 answer
Catching OverflowError
In Python 3 I have a class representing a range [x,y] of values and computing the length of such range.
If the length is too large, I'm not sure how to catch the OverflowError exception inside the class itself. It is raised only in the outer code…

Ricky Robinson
- 21,798
- 42
- 129
- 185
2
votes
2 answers
What is the safest way to subtract two System.Runtime.InteropServices.ComTypes.FILETIME objects
I wonder what is the safest way to subtract two System.Runtime.InteropServices.ComTypes.FILETIME objects? I used the following code but sometimes it gives me ArithmaticOverflow exception due to the negative number in Low 32-bit values. I am not sure…

Anindya Chatterjee
- 5,824
- 13
- 58
- 82
2
votes
2 answers
FileStream Overflow Exception
Get an overflow exception when trying to run an eof statement in the while loop Value was either too large or too small for a character
string filePath = @"C:\Users\Klanix\Desktop\NewC#\testfile2.txt";
FileStream fs = File.Open(filePath,…

ThatOneCoderDude
- 45
- 3
2
votes
0 answers
Why is an OverflowException raised in this situation?
Why isn't this code idempotent?
double.Parse(double.MinValue.ToString())
This will throw an OverflowException with the message
Value was either too large or too small for a Double
I would expect this expression to result in a double whose value…

Kirk Woll
- 76,112
- 22
- 180
- 195
2
votes
1 answer
Arithmetical Exceptions
I'm in a programming high school course, and my assignment is to write a program that uses: OverflowException, or NotFiniteNumberException. It has to be arithmetical and I've tried everything I can think of, but I can't seem to get it to print…

Kylie
- 51
- 3
2
votes
0 answers
OverflowException with NHibernate and Oracle SDO_ORDINATE_ARRAY
I'm getting an OverflowException when trying to query an SDO_ORDINATE_ARRAY from an Oracle database with NHibernate.
The exception is thrown in Oracle.DataAcess in the public static unsafe object GetValue(OracleConnection con, IntPtr pUdt, int…

knittl
- 246,190
- 53
- 318
- 364
2
votes
1 answer
System.OverflowException in serialization
I have a some classes for parse the web response:
[DataContract]
public abstract class GYResponse
{
[DataMember(Name = "code")]
public int Code { get; set; }
[DataMember(Name = "message")]
public string Message { get; set;…

Alexandr
- 1,891
- 3
- 32
- 48