Sign in to follow this  
Followers 0
mrflibblehat

Add Up Decimal Points and Increment

8 posts in this topic

#1 ·  Posted (edited)

So i have a value of 0.000001 and I want it to increment by 0.000001 every second.

Everytime I try this I just get a rounded number of 1 and not 0.000002, 0.000003, 0.000004 as expected.

Please can anyone help

I must add this this needs to be shown in a label on the gui

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 386, 95, 192, 124)
$Label1 = GUICtrlCreateLabel("Label1", 64, 24, 228, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$vDec = 0.000001
$vDec2 = 0.000002

$vAdd = $vDec + $vDec2

GUICtrlSetData($Label1, $vAdd)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Im sure its something to do with strings/dec/int but I cant work it out.

Edited by mrflibblehat

[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Share this post


Link to post
Share on other sites



Can you please be so kind and post the code you use? Or at least a small reproducer script?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Because 0.000001 is 1*10-6 you will get results like "1e-006" by AutoIt.

Example:

For $i = 0.000001 To 0.0001 Step 0.000001
    ConsoleWrite($i & @LF)
Next

returns:

1e-006
2e-006
3e-006
4e-006
5e-006
6e-006
7e-006
8e-006
9e-006
1e-005
1.1e-005
1.2e-005
1.3e-005
1.4e-005
1.5e-005
1.6e-005
1.7e-005
1.8e-005
1.9e-005
2e-005
2.1e-005
2.2e-005
2.3e-005
2.4e-005
2.5e-005
2.6e-005
2.7e-005
2.8e-005
2.9e-005
3e-005
3.1e-005
3.2e-005
3.3e-005
3.4e-005
3.5e-005
3.6e-005
3.7e-005
3.8e-005
3.9e-005
4e-005
4.1e-005
4.2e-005
4.3e-005
4.4e-005
4.5e-005
4.6e-005
4.7e-005
4.8e-005
4.9e-005
5e-005
5.1e-005
5.19999999999999e-005
5.29999999999999e-005
5.39999999999999e-005
5.49999999999999e-005
5.59999999999999e-005
5.69999999999999e-005
5.79999999999999e-005
5.89999999999999e-005
5.99999999999999e-005
6.09999999999999e-005
6.19999999999999e-005
6.29999999999999e-005
6.39999999999999e-005
6.49999999999999e-005
6.59999999999999e-005
6.69999999999999e-005
6.79999999999999e-005
6.89999999999999e-005
6.99999999999999e-005
7.09999999999999e-005
7.19999999999999e-005
7.29999999999999e-005
7.39999999999999e-005
7.49999999999999e-005
7.59999999999999e-005
7.69999999999999e-005
7.79999999999999e-005
7.89999999999999e-005
7.99999999999999e-005
8.09999999999999e-005
8.19999999999999e-005
8.29999999999999e-005
8.39999999999999e-005
8.49999999999999e-005
8.59999999999999e-005
8.69999999999999e-005
8.79999999999998e-005
8.89999999999998e-005
8.99999999999998e-005
9.09999999999998e-005
9.19999999999998e-005
9.29999999999998e-005
9.39999999999998e-005
9.49999999999998e-005
9.59999999999998e-005
9.69999999999998e-005
9.79999999999998e-005
9.89999999999998e-005
9.99999999999998e-005

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

Because 0.000001 is 1*10-6 you will get results like "1e-006" by AutoIt.

Example:

For $i = 0.000001 To 0.0001 Step 0.000001
    ConsoleWrite($i & @LF)
Next

returns:

1e-006
2e-006
3e-006
4e-006
5e-006
6e-006
7e-006
8e-006
9e-006
1e-005
1.1e-005
1.2e-005
1.3e-005
1.4e-005
1.5e-005
1.6e-005
1.7e-005
1.8e-005
1.9e-005
2e-005
2.1e-005
2.2e-005
2.3e-005
2.4e-005
2.5e-005
2.6e-005
2.7e-005
2.8e-005
2.9e-005
3e-005
3.1e-005
3.2e-005
3.3e-005
3.4e-005
3.5e-005
3.6e-005
3.7e-005
3.8e-005
3.9e-005
4e-005
4.1e-005
4.2e-005
4.3e-005
4.4e-005
4.5e-005
4.6e-005
4.7e-005
4.8e-005
4.9e-005
5e-005
5.1e-005
5.19999999999999e-005
5.29999999999999e-005
5.39999999999999e-005
5.49999999999999e-005
5.59999999999999e-005
5.69999999999999e-005
5.79999999999999e-005
5.89999999999999e-005
5.99999999999999e-005
6.09999999999999e-005
6.19999999999999e-005
6.29999999999999e-005
6.39999999999999e-005
6.49999999999999e-005
6.59999999999999e-005
6.69999999999999e-005
6.79999999999999e-005
6.89999999999999e-005
6.99999999999999e-005
7.09999999999999e-005
7.19999999999999e-005
7.29999999999999e-005
7.39999999999999e-005
7.49999999999999e-005
7.59999999999999e-005
7.69999999999999e-005
7.79999999999999e-005
7.89999999999999e-005
7.99999999999999e-005
8.09999999999999e-005
8.19999999999999e-005
8.29999999999999e-005
8.39999999999999e-005
8.49999999999999e-005
8.59999999999999e-005
8.69999999999999e-005
8.79999999999998e-005
8.89999999999998e-005
8.99999999999998e-005
9.09999999999998e-005
9.19999999999998e-005
9.29999999999998e-005
9.39999999999998e-005
9.49999999999998e-005
9.59999999999998e-005
9.69999999999998e-005
9.79999999999998e-005
9.89999999999998e-005
9.99999999999998e-005

Thanks Water,

Does that mean that there is no way to get to what I want to achieve? 


[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

Share this post


Link to post
Share on other sites

Function StringFormat comes to my mind. But I haven't tried it yet ...


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You need something like this:

For $i = 0.000001 To 0.0001 Step 0.000001
    ConsoleWrite(StringFormat("%1.6f", $i) & @LF)
Next
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 386, 95, 192, 124)
$Label1 = GUICtrlCreateLabel("0.000001", 64, 24, 228, 33)
GUISetState()

$vDec = 0.000001
AdLibRegister("_add", 500)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _add()
   $vDec = $vDec + 1*10^-6
   GUICtrlSetData($Label1, StringFormat("%.6f", $vDec))
EndFunc

1 person likes this

Share this post


Link to post
Share on other sites

Thank you both for your very details answers, but Mikells helped me out perfectly


[font="'courier new', courier, monospace;"]Pastebin UDF | Prowl UDF[/font]

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  
Followers 0