Jump to content

Scientific notation


 Share

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...