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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Long number being rounded in formula

Status
Not open for further replies.

mgallot

MIS
Jan 22, 2001
93
US
Hello,
I have a hexadecimal value which I converted to decimal with the following formula:

StringVar HexValue:= {SP_CALL_RECORD.CONN_ID};
NumberVar DecValue:=0;
NumberVar Factor:=1;
NumberVar j:=0;
NumberVar x;

for j := len(HexValue) to 1 step -1
do
(
if asc(uppercase(HexValue[j])) in 65 to 70 then
tmpVal := asc(uppercase(HexValue[j])) - 55
else
tmpVal := val (HexValue[j]);
if (j=16) then
x := tmpVal*Factor;

DecValue := DecValue + (Factor * tmpVal);

Factor := Factor * 16
);

DecValue

The problem is, the result is a very large number (17 digits), and it is being rounded to the hundreds place. I have tried converting the value with the ToText function, but the rounding still occurred. Any ideas?

Thanks!
 
default number format is 2 decimal places

place on report, right click and select format tab.

You can then set decimal places and rounding as required.

Ian
 
Please show a sample of the result you are getting and then show how it should be displayed.

-LB
 
Input: 0071018d49c6284b
Actual Output: 31808378708043900
Desired Output: 31808378708043851

I also tried setting the formula to display a constant 17 digit value, and it is still rounded to the hundreds place. It seems like Crystal doesn't like numbers over 15 digits?
 
Oh, also please ignore anything involving the variable "x" in my first post, I was experimenting with it and forgot to take it out.
 
The only way I've seen to display a very long number in CR is to use a SQL expression like:

{fn convert(table.`longno`, sql_varchar)}

This returns the actual number, instead of a rounded version. However, I'm not sure how to build your entire conversion into a SQL expression. You also could try doing it in a command--I'm just not sure how to generate the equivalent of your conversion in either place.

-LB
 
Thanks for your reply, I will see if theres anyway I can convert this to SQL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top