dear there,
with offset of type signed int, and both curprice and prevprice of type double. I compute the offset as this:
offset = (signed int) ((curprice - prevprice) * 10000);
the result is not consistent.
curprice offset
1.239 0
1.2391 0 <=====
1.2389 -2
1.2389 0
1.239 1
I also tried to cast it this way:
offset = (signed int)(curprice*10000) - (signed int)(prevprice * 10000);
and the result is not consistent neither.
1.2393 0
1.2393 0
1.2392 -1
1.2391 -1
1.2391 0
1.2391 0
1.2391 0
1.2389 -3 <=====
the curprice and prevprice are read from text file, which always has 4 digits after decimal point: 1.xxxx.
can anybody show me how to cast it? Thanks!