Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

algorithm question

Status
Not open for further replies.

uksub

Programmer
Jun 15, 2003
51
US
I have a number:

491,514,688.43

which i want to convert to

491,514.688

when I use my algorithm in Crystal Reports... it rounds the number to

491,514.69

anyone have any suggestions?

thanx
 
Crystal has it's own ideas about handling numeric fields, but I would think if you just use the Truncate() function, you would get the expected result. What algorithm are you using?
 
I think you need to truncate the field first and then do the division.

Create the following formula:
local numbervar x := truncate({YourNumberField});
x := x / 1000;
x;


HOWEVER, I will bet money that this will not always return the correct value. You need to deal with these numbers in your database to ensure the correct values. But, this should work most of the time.
 
I'm not sure you even need the variable. Truncate(x)/1000 should be cool.
 
hi guys... using truncate (x) /1000 or similar algorithms still rounds the number up i.e.

491,514,688.43

becomes 491514.69 or 491,486.00

what i need is the account format of 491514.668


so what i did was

1. (491,514, 688.43 * .001) this moves the decimal 5 places to the left

2. format with 1.000 decimal places to 3 decimal places.

3. and finally...

round to the thousandths position
which give me 491,514.688


thanx for the help. :-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top