By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,433 Members | 776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,433 IT Pros & Developers. It's quick & easy.

project wide settings

P: n/a
Is it possible in project settings to set vb.net in such a way so that it
considers only upto 3 decimal places when comparing any two values.

My problem is:

i get varA = -0.0000000000018189894035458565. It actaully should be zero.
So when i compare varA = 0 , it returns false (obviously)
I can use round(varA) to achieve what i want, but i have to do that every
time. Is it possible to set it in project settings.

Irfan

Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
No. You can't change the way basic mathematical operators work. Especially
on a per project setting, since in the end, the IL is interpreted by the
CLR, who doesn't know or care what project your assembly was compiled in. It
treates all floating point numbers the same way, it's not going to treat
them differently depending on what assembly the code is executing in.

I would suggest you write a function to do the comparison, that will then do
the rounding appropriately. That way comparing 2 numbers is still one call
and you don't have messy rounding code all over the place.

"Irfan Mumtaz" <sp****@spam.net> wrote in message
news:1C**********************************@microsof t.com...
Is it possible in project settings to set vb.net in such a way so that it
considers only upto 3 decimal places when comparing any two values.

My problem is:

i get varA = -0.0000000000018189894035458565. It actaully should be zero.
So when i compare varA = 0 , it returns false (obviously)
I can use round(varA) to achieve what i want, but i have to do that every
time. Is it possible to set it in project settings.

Irfan


Nov 21 '05 #2

P: n/a
thanks Marina for the reply

I will probably create my own function

irfan
"Marina" wrote:
No. You can't change the way basic mathematical operators work. Especially
on a per project setting, since in the end, the IL is interpreted by the
CLR, who doesn't know or care what project your assembly was compiled in. It
treates all floating point numbers the same way, it's not going to treat
them differently depending on what assembly the code is executing in.

I would suggest you write a function to do the comparison, that will then do
the rounding appropriately. That way comparing 2 numbers is still one call
and you don't have messy rounding code all over the place.

"Irfan Mumtaz" <sp****@spam.net> wrote in message
news:1C**********************************@microsof t.com...
Is it possible in project settings to set vb.net in such a way so that it
considers only upto 3 decimal places when comparing any two values.

My problem is:

i get varA = -0.0000000000018189894035458565. It actaully should be zero.
So when i compare varA = 0 , it returns false (obviously)
I can use round(varA) to achieve what i want, but i have to do that every
time. Is it possible to set it in project settings.

Irfan



Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.