| | |
How to compare floating point values
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
Hi Everybody,
I am trying to compare single precision floating point values in VB .NET. The code runs ok but the results look not right. Results also contain -Inf values. I see that this is not the right way of comparing floating points. Could you please show me how to compare these? Thank you so much.
I am trying to compare single precision floating point values in VB .NET. The code runs ok but the results look not right. Results also contain -Inf values. I see that this is not the right way of comparing floating points. Could you please show me how to compare these? Thank you so much.
VB.NET Syntax (Toggle Plain Text)
For m = 0 To fLen1 - 1 If snglRead1(m) >= -1.0 And snglRead1(m) <= -0.18 Then snglOutput(m) = 0.985 ElseIf snglRead1(m) > -0.18 And snglRead1(m) <= 0.157 Then snglOutput(m) = 0.955 ElseIf snglRead1(m) > 0.157 And snglRead1(m) <= 0.727 Then snglOutput(m) = Math.Log(snglOutput(m)) ElseIf snglRead1(m) > 0.727 And snglRead1(m) <= 1.0 Then snglOutput(m) = 0.99 End If bw.Write(snglOutput(m)) Next
“Remember: If you’re not experiencing failure, you’re not working hard enough!”
Jeffrey J. Mayer
Jeffrey J. Mayer
Hmm, I asked the wrong question, I meant: what does the function snglRead1() do? Do you have the code for it?
I'm guessing the function reads one float from a file? If thats the case, then this line:
will probably read the first and second number from the file and compare the two. This is not what you want, so read one float and store it in a variable. Then compare it to your values.
Niek
I'm guessing the function reads one float from a file? If thats the case, then this line:
VB.NET Syntax (Toggle Plain Text)
If snglRead1(m) >= -1.0 And snglRead1(m) <= -0.18
Niek
![]() |
Similar Threads
- Python bug??? Or just a stupid question? (Python)
- Please help, im new at this :/ (C)
- what's with gcc? (C++)
- matlab program help (Legacy and Other Languages)
- Why is it so? (C)
- Applet Help (Java)
Other Threads in the VB.NET Forum
- Previous Thread: Datagride column width
- Next Thread: how to control a buttons with parallel port interfacing
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview map mobile module monitor msaccess mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year






