The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with value of a double
#1
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
Code:
Copy      Help
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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)