05-20-2013, 04:23 AM

Hello,

I have a macro that automates the playing of roulette and I am trying to improve the speed of bet placement by having the macro determine the correct chip size based on the bet amount. This works well, however if the remaining bet is less than 1 and not equal to one of the unit sizes, the number is not accurately calculated and hence the last bet is not correct.

Macro Calulate Bet

In the above, if nextBet is 9.5 it calculates each unit and number of units fine and exits the loop correctly betting .50 as last bet of one unit.

However if it is 9.2 it fails to determine the remainder correctly on the last step of the loop and returns 0.199999999 instead of .20, thus messing up the last bet.

I am sure this is an error with the variable type but not sure how to work around it?

Thanks kindly

Matt

I have a macro that automates the playing of roulette and I am trying to improve the speed of bet placement by having the macro determine the correct chip size based on the bet amount. This works well, however if the remaining bet is less than 1 and not equal to one of the unit sizes, the number is not accurately calculated and hence the last bet is not correct.

Macro Calulate Bet

`ARRAY(double) unit`

unit.create(6)

unit[0]=0.10

unit[1]=0.50

unit[2]=1

unit[3]=5

unit[4]=25

unit[5]=100

double nextBet=9.50

int inc

double chipValue

int chipAmount

double chipAmount1

double Remainder=nextBet

rep

,for inc 0 unit.len

,,if unit[inc]>=Remainder

,,,if unit[inc]=Remainder

,,,,chipValue=unit[inc]

,,,,break

,,,chipValue=unit[inc-1]

,,,break

,,else

,,,chipValue=unit[unit.len-1]

,chipAmount=Remainder/chipValue

,Remainder=Remainder-(chipAmount*chipValue)

,mes chipValue

,mes chipAmount

,mes Remainder

,if Remainder=0

,,break

,

In the above, if nextBet is 9.5 it calculates each unit and number of units fine and exits the loop correctly betting .50 as last bet of one unit.

However if it is 9.2 it fails to determine the remainder correctly on the last step of the loop and returns 0.199999999 instead of .20, thus messing up the last bet.

I am sure this is an error with the variable type but not sure how to work around it?

Thanks kindly

Matt