Jump to content
Sign in to follow this  
dbkaynor

Scientific notation

Recommended Posts

dbkaynor

Is there a function to convert scientific notation to a decimal number? I am using GUICtrlCreateInput to get a value to use in calculations. It works fine with decimal numbers but with scientific notation the read value is correct in string form but wrong when converted to a number

;----- Sample code ------

#include <GUIConstants.au3>

Global $Form1 = GUICreate(@ScriptName, 250, 220, 10, 10)

Global $ButtonTest = GUICtrlCreateButton("Test", 10, 10, 70, 20)

Local $InputTest = GUICtrlCreateInput("1", 90, 10, 150, 20, -1)

GUISetState(@SW_SHOW)

While 1

Local $msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

ExitLoop

Case $ButtonTest

local $T = GUICtrlRead($InputTest)

Local $msg = "In:" & $T & " Out:" & $T * 1

MsgBox(0, "test", $msg)

EndSwitch

WEnd

Share this post


Link to post
Share on other sites
erezlevi

Is there a function to convert scientific notation to a decimal number? I am using GUICtrlCreateInput to get a value to use in calculations. It works fine with decimal numbers but with scientific notation the read value is correct in string form but wrong when converted to a number

;----- Sample code ------

#include <GUIConstants.au3>

Global $Form1 = GUICreate(@ScriptName, 250, 220, 10, 10)

Global $ButtonTest = GUICtrlCreateButton("Test", 10, 10, 70, 20)

Local $InputTest = GUICtrlCreateInput("1", 90, 10, 150, 20, -1)

GUISetState(@SW_SHOW)

While 1

Local $msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

ExitLoop

Case $ButtonTest

local $T = GUICtrlRead($InputTest)

Local $msg = "In:" & $T & " Out:" & $T * 1

MsgBox(0, "test", $msg)

EndSwitch

WEnd

Hi,

can you send the numbers that you try to convert to and from?

Share this post


Link to post
Share on other sites
weaponx

You can use Execute()

#include <GUIConstants.au3>

Global $Form1 = GUICreate(@ScriptName, 250, 220, 10, 10)
Global $ButtonTest = GUICtrlCreateButton("Test", 10, 10, 70, 20)
Local $InputTest = GUICtrlCreateInput("10e3", 90, 10, 150, 20, -1)

GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ButtonTest
            local $T = GUICtrlRead($InputTest)
            Local $msg = "In:" & $T & " Out:" & Execute($T)
        MsgBox(0, "test", $msg)
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
erezlevi

You can use Execute()

#include <GUIConstants.au3>

Global $Form1 = GUICreate(@ScriptName, 250, 220, 10, 10)
Global $ButtonTest = GUICtrlCreateButton("Test", 10, 10, 70, 20)
Local $InputTest = GUICtrlCreateInput("10e3", 90, 10, 150, 20, -1)

GUISetState(@SW_SHOW)

While 1
    Local $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $ButtonTest
            local $T = GUICtrlRead($InputTest)
            Local $msg = "In:" & $T & " Out:" & Execute($T)
        MsgBox(0, "test", $msg)
    EndSwitch
WEnd
Nice!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×