I got a CER from a client said that a system.overflowexception thrown
when executing the following stentence:
Vertor3 v = p1 - p2;
Here the p1, p2 are variables of self defined struct --- Point3,
Vector3 is also a self defined struct type, they are definitions as
below:
struct Point3 struct
Vector3
{ {
float x, y, z;
float x, y, z;
} }
Point3 overode its -operation:
struct Point3
{
public static Vector3 operator - (Point3 p1, Point3 p2)
{
return new Vector3(p1.x-p2.x, p1.y - p2.y, p1.z - p2.z);
}
}
As I know that the arithmetic between the float type never throw
system.overflowexception.
So, the exception only can be thrown when create a Vector3.
Vector3 has three type constructs:
1. public Vector3(float x, float y, float z)
2. public Vector3(double x, double y, double z)
3. public Vector3(int x, int y, int z)
That means during runtime the construct --- Vector3(int x, int y, int
z) was invoked which eventually caused this exception.
Does anyone could help me to explain how could this case happen? or
there are some errors in my analysis?
Thanks,
Steven 4 3423
That means during runtime the construct --- Vector3(int x, int y, int z) was invoked
What makes you think this? Can you post the ctor code at all? float-
float=float, so your line Vector3(p1.x-p2.x, p1.y - p2.y, p1.z -
p2.z) should invoke Vector3(float,float,float). Eitherway, float will
do an implicit cast to double, but not to int - so it won't be using
the int ctor unless you are twisting its arm.
I think the devil may be in the detail here... can you post the actual
code for Point3 and Vector3 at all? In particular the - operator, the
constructor, and the field/property members for x,y,z
Marc
Thank you Marc and I so impressed for the quick reply.
The Vector3's constructors as following:
public struct Vector3
{
float _x, _y, _z;
public Vector3(int x, int y, int z)
{
_x = x;
_y = y;
_z = z;
}
public Vector3(float x, float y, float z)
{
_x = x;
_y = y;
_z = z;
}
public Vector3(double x, double y, double z)
{
_x = (float)x;
_y = (float)y;
_z = (float)z;
}
}
I thought that the system.overflowexception only could be thrown by an
integer type, so I guessed the constructor Vector3(int x, int y, int
z) being called.
The -operation of the Point3 just exactly as I wrote.
For the whole actual code, because I am in home now, you know, I can
not recall it nicely.
Thank you for your reply again.
Steven
}
Hi,
Did you try to debug it? and go into the methods?
Also a short but a complete example will help as we could run it and try
ourselves.
--
Ignacio Machin http://www.laceupsolutions.com
Mobile & warehouse Solutions.
<st**************@126.comwrote in message
news:11**********************@e34g2000pro.googlegr oups.com...
>I got a CER from a client said that a system.overflowexception thrown
when executing the following stentence:
Vertor3 v = p1 - p2;
Here the p1, p2 are variables of self defined struct --- Point3,
Vector3 is also a self defined struct type, they are definitions as
below:
struct Point3 struct
Vector3
{ {
float x, y, z;
float x, y, z;
} }
Point3 overode its -operation:
struct Point3
{
public static Vector3 operator - (Point3 p1, Point3 p2)
{
return new Vector3(p1.x-p2.x, p1.y - p2.y, p1.z - p2.z);
}
}
As I know that the arithmetic between the float type never throw
system.overflowexception.
So, the exception only can be thrown when create a Vector3.
Vector3 has three type constructs:
1. public Vector3(float x, float y, float z)
2. public Vector3(double x, double y, double z)
3. public Vector3(int x, int y, int z)
That means during runtime the construct --- Vector3(int x, int y, int
z) was invoked which eventually caused this exception.
Does anyone could help me to explain how could this case happen? or
there are some errors in my analysis?
Thanks,
Steven
And Point3? again, in particular the properties/fields... I can't seee
anything obvious; are you sure about where it blows up?
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brandon J. Van Every |
last post by:
I'm realizing I didn't frame my question well.
What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
up in your chair and scream "Wow! Ruby has *that*? That is SO...
|
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: CSharpX |
last post by:
I have the following code and when the exception is raised the OS displays a nasty Stop dialog box
it says an unhandled exception occured, gives 3 buttons to click details, contintue Quit... i do...
|
by: Amin Sobati |
last post by:
Hi,
I have the following code in my app:
Dim intx As Integer
Dim inty As Integer
Dim intz As Integer
inty = 0
intx = 5
Try
intz = intx / inty
|
by: Andrea |
last post by:
....without changing the data type. I have been working on this for over 5 hours, please help me so I don't have to shoot myself. It's due by midnight...
Here's my code:
(Variables are declared...
|
by: Patrick Dickey |
last post by:
Hello, All!
I'm modifying some source code that I downloaded from
Planet-source-code a while back, and have a question about Try Catch
statements. Basically, I'm wondering if I can do a Try with...
|
by: Nathan Sokalski |
last post by:
During my postbacks, I try to assign the value from an Input tag to a
property of a custom control. However, I keep recieving the following error:
An exception of type...
|
by: stevencheng_2007 |
last post by:
I got a CER from a client said that a system.overflowexception thrown
when executing the following stentence:
Vertor3 v = p1 - p2;
Here the p1, p2 are variables of self defined struct --- Point3,...
|
by: =?Utf-8?B?RWR3YXJk?= |
last post by:
Hi everybody,
I was testing a piece of code and I noticed that try catch block doesn't
recognize "DivideByZeroException" when I have zero in denominator and I have
to use the "OverflowException" ,...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |