Good day to all, I encountered the following problem: There is some written program in C ++ Builder 6 that performs the server role, polls the pci modules and performs the necessary calculation, then writes the data to the bin. file and DB, then the client can view the necessary information, but the fact is that when the module is polled, the thousandth walks, which participates in the calculation, and I want to round this thousandth, the spread range is not large + -1 thousand. I decided to use the RoundTo function but I was not helped by the thousandth as I was walking and walking. Then I decided to see what was happening, I created a test example:

float t,a = 1.001,Hl,Hh; t=a; t=RoundTo(t, -2); Hl=t-(t*.15); Hh=t+(t*.15); Chart1->LeftAxis->SetMinMax(Hl,Hh); Label1->Caption = Hl; 

With a value of 1.001, it is not particularly noticeable, but if, for example, the following fall. data 1,151 and then you can see 1,977499961853027 - this answer does not suit me and if you count on a calculator, we get the number 0.97835 which also does not suit me, because as I said above, the thousandth walks by + -1 and should be instead of 1.151 - 1,150 and at 1,150 the value is 0.9775 which is what I need. After reading a lot of information, I realized that the problem with types, namely when I changed the type from float to double, my data began to be displayed as I needed, but I do not want to change the type, how to implement the same result but with the type float?

  • Still important, your help is very necessary, help me sort it out please, thanks. - Ethernets

0