Implementation of Regular Expression Code

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

Guest

In the sample code for Programming Microsoft Visual Basic.NET by Francesco
Balena (Microsoft Press) there is a program (ExprEvaluator) that evaluates
expressions. It has a bug in that when the expression evaluates to a near
zero value(i.e. one that the system expresses in scientific notation), a
system error occurs.

For example sin(3.1415927) or 1-0.999999

I would like to use the fundamentals in a broader application where I will
need to be able to evaluate expression that result in numbers like 1.342 E -6.

How might this be done?

Is it possible to force the system to express low numbers in standard
notation (.000001342)?
 
You could use this

Module Module1

Sub Main()
System.Diagnostics.Debug.WriteLine(CType(0.000001342,
Double).ToString("N10"))
End Sub

End Module

which prints it like you want, but I don't know how to make it calculate the
precision itself (I've hardcoded it here as 10).

Also check out the "R" standard format specifier, which specifies round
trip. It means that if you parse the string back into a number, you will get
the same number back.
 

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