Rskm Posted March 26, 2018 Share Posted March 26, 2018 hi, i have the following function to get a number in scientific format. my input is 12360 what i get using the below function = 1.236E+004 What i require is 1.236E4 how do i achieve this. i do not require the '+00'prefixing '4 or whatever' in my o/p. Func _FXTY($inumber) return stringformat("%01.3E",$inumber) Endfunc Link to comment Share on other sites More sharing options...
funkey Posted March 26, 2018 Share Posted March 26, 2018 (edited) Local $var = 0.0001236000000 ConsoleWrite(_FXTY($var) & @CRLF) ConsoleWrite(_FXTY_old($var) & @CRLF) $var = 1236000000 ConsoleWrite(_FXTY($var) & @CRLF) ConsoleWrite(_FXTY_old($var) & @CRLF) Func _FXTY($inumber) Local $s = stringformat("%01.3E",$inumber) Local $a = StringSplit($s, "E") Return $a[1] & "E" & Int($a[2]) Endfunc Func _FXTY_old($inumber) Return stringformat("%01.3E",$inumber) Endfunc Edited March 26, 2018 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Rskm Posted March 27, 2018 Author Share Posted March 27, 2018 On 3/26/2018 at 2:22 PM, funkey said: Local $var = 0.0001236000000 ConsoleWrite(_FXTY($var) & @CRLF) ConsoleWrite(_FXTY_old($var) & @CRLF) $var = 1236000000 ConsoleWrite(_FXTY($var) & @CRLF) ConsoleWrite(_FXTY_old($var) & @CRLF) Func _FXTY($inumber) Local $s = stringformat("%01.3E",$inumber) Local $a = StringSplit($s, "E") Return $a[1] & "E" & Int($a[2]) Endfunc Func _FXTY_old($inumber) Return stringformat("%01.3E",$inumber) Endfunc thanks. that helped Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now