Forums: Displaying numeric values in scientific notation - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Displaying numeric values in scientific notation

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16435
  • Joined: 03-February 03
  • Gender:Male

Posted 16 March 2019 - 02:48 PM

Here is how you can display numbers in scientific notation in your ASPRunnerPro application.

1. In source subfolder under you project folder create a file named scientific.asp and paste the following code there:


<%

Function NSN(Number, Accuracy)
  Exponent = 0
  If Number > 0 Then
    Sign = 1
  ElseIf Number < 0 Then
    Sign = -1
  Else
    NSN = 0
    Exit Function
  End If
  Number = Number * Sign
  If Number >= 10 Then
    While Number >= 10
      Number = Number / 10
      Exponent = Exponent + 1
    Wend
  ElseIf Number < 1 Then
    While Number < 1
      Number = Number * 10
      Exponent = Exponent - 1
    Wend
  End If
  Number = Round(Number, Accuracy)
  If Number = "10" Then
    Number = 1
    Exponent = Exponent + 1
  End If
  Number = Number * Sign
  If Exponent = 0 Then
    NSN = Number
  Else
    NSN = Number & "E" & Exponent
  End If
End Function

%>


2. In AfterAppInit event add the following code:

asp_include "scientific.asp",false


This will make functions defined in scientific.asp file available in ASPRunnerPro project.

3. Set 'View as' type of this field to Custom and paste the following code there:

strValue = NSN(strValue, 4)

Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users