project wide settings

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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.
 
thanks Marina for the reply

I will probably create my own function

irfan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top