Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

force a trailing zero?

$
0
0

Greetings,

 

 

  In the sample code example below I am attempting to create a search through an array for a variable that is within .01 of the original, above and below.  My original variable is ".49" ($_ACTUAL_INTEREST) and the ".01" is declared as the "$_ACTUAL_DIV1"...the array to search is "$_F_HI_SET".  Thus in this example I am searching for .48 and .50, which are .49 - .01 and .49 + .01 respectively:

Global $_F_HI_SET[10] = [.42, .46, .52, .58, .48, .46, .50, .53, .56, .51] Global $_ACTUAL_DIV1 = .01 Global $_ACTUAL_INTEREST = .49          For $_IDX = 0 to Ubound($_F_HI_SET) - 1           if StringInStr($_F_HI_SET[$_IDX], Round($_ACTUAL_INTEREST + ($_ACTUAL_DIV1), 2))) > 0 Then     ;do stuff as a value in the array matches the search value...higher     EndIf  ;StringInStr($_F_HI_SET[$_IDX] is a 'higher' sequence match...     if StringInStr($_F_HI_SET[$_IDX], Round($_ACTUAL_INTEREST - ($_ACTUAL_DIV1), 2))) > 0 Then     ;do stuff as a value in the array matches the search value...lower     EndIf  ;StringInStr($_F_HI_SET[$_IDX] is a 'lower' sequnce match...    Next  ;Next $_IDX...cycle thru '$_F_HI_SET' to find values that equal the 'comparison'          ;($_ACTUAL_INTEREST) +/- ($_ACTUAL_DIV1) value...  

  The code works fine except I have a problem when the searched value ends with a "0".  In this example the ".48" is found without any problems however unintended values are returned when scanning for the ".50" value...because instead of searching for ".50" it instead returns any value beginning with ".5"...thus I get returns of .52, .58, .53, .56, .51 in addition to the .50 that is what is intended.

 

 

  I thought I could fix this by using a 'Round' command of 2 decimal places however it seems to have no effect.  I'm looking for any information on how I might correct this.  Any advice greatly appreciated.  I thank you in advance.   


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>