Home > Back-end >  Questions about DELPHI float processing
Questions about DELPHI float processing

Time:10-27

I was five decimal places of float type data
Calculate storage to 3 decimal places after object
Lead to data finally lost 2 decimal places content into 0.00
For a better solution

CodePudding user response:

Since only 3 decimal places, that is sure to truncate the last 2 decimal places,
Can expand 100 times, do the opposite when use reduction operation, but should pay attention to overflow,

CodePudding user response:

reference 1st floor andrew57 response:
since only 3 decimal places, it will certainly be truncated last 2 decimal places,
Can expand 100 times, do the opposite when use reduction operation, but should pay attention to overflow,

May be too small cause in fact, the key is to calculate the price itself of five time is 0.00001
Finally gone don't have to pay a penny

CodePudding user response:

Put the object,

CodePudding user response:

The
reference 3 floor lhylhy response:
to rewrite the object,

I now use the judging is calculated if is 0.00 let him get 0.01
I want to ask you is there any better way

CodePudding user response:

It is "less than a minute from a point of the", namely 0.00999, then Trunc do cutting processing,

CodePudding user response:

reference 4 floor neilyo0609 response:
reference 3 floor lhylhy reply: put the object,
I now use the judging is calculated if is 0.00 let him get 0.01
I want to ask you is there any better way

More space to the data distribution, to save a few,

CodePudding user response:

A monthly salary of 35010 yuan, you can directly write 35010 yuan,
A product 95 discount, can be understood as 0.95
Can also be used for 95/100

CodePudding user response:

A lot of the stars above

CodePudding user response:

Suggest modify the data type, if there is not willing to change, can be considered in the method, namely 0.00, 0.01 ten percent after data directly into judgment, rather than simply see 0.00=0.01
Unless you can rule out without 0.00000
  • Related