eos icon indicating copy to clipboard operation
eos copied to clipboard

Transaction time takes too long when doing float multiplication

Open PhillipHamnett opened this issue 8 years ago • 2 comments

I consistently get the message: Error 3080006: Transaction took too long everytime that I include the following line of code: result += int(x)*factor; Where x is a number, and factor is a double which is less than 1.

The same code works if factor is 10, or 100. But it fails with transaction taking too long everytime factor is 0.1 or 0.01.

PhillipHamnett avatar Aug 06 '18 13:08 PhillipHamnett

interesting, floating point operation takes more time?

spartucus avatar Aug 07 '18 01:08 spartucus

all floating point operations are emulated using integer operations. However, the timing is also affected by your actual machine speed. You can either optimize it by using pure integer operations or try to have less number of floating point ops.

taokayan avatar Aug 07 '18 10:08 taokayan