I got a CER from a client said that a system.overflow exception 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.overflow exception.
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 3459
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,f loat,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.overflow exception 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.goo glegroups.com.. .
>I got a CER from a client said that a system.overflow exception 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.overflow exception.
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 FRICKIN'
COOL!!! ***MAN*** that would save me a buttload of work and make my life
sooooo much easier!"
As opposed to minor differences of this feature here, that feature there.
Variations on style are of no interest to me. I'm coming at this from a...
|
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 software giant such as Microsoft SQL
Server, Oracle, and Sybase?
Is PostgreSQL reliable enough to be used for high-end commercial
application? Thanks
|
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 not want this ugly thing to display, what am i missing from the code below? am i not catching that exception and displaying my own error message? so why is the other one coming up after mine
public bool isInteger(string str
int i=0
bool...
|
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 as Short, therefore any sum over 32767 causes an overflow exception.)
If RadioButton1.Checked = True Then
Try
TextBox3.Text = FirstNum + SecondNum
| |
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 multiple Catch
statements, or do I have to figure out how to embed Try Catch statements
into my code. The scenario is this (and I'll paste the actual code at the
bottom of this post). I'm modifying a web browser, and in the About Help
box, it...
|
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 'System.OverflowException' occurred in
Microsoft.VisualBasic.dll but was not handled in user code
Additional information: Arithmetic operation resulted in an overflow.
The code that it highlights during this error is the 2nd line of the
|
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,
Vector3 is also a self defined struct type, they are definitions as
below:
struct Point3 struct
Vector3
{ {
|
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" , I can't figure out why VB behaves this way ,
Any thoughts?
--
Best regards,
Edward
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |