ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBNumeric.pas
(Generate patch)

Comparing ibx/branches/udr/client/FBNumeric.pas (file contents):
Revision 381 by tony, Sat Jan 15 00:06:22 2022 UTC vs.
Revision 383 by tony, Sat Jan 15 16:02:25 2022 UTC

# Line 231 | Line 231 | begin
231   end;
232  
233   function NumericToDouble(aValue: Int64; aScale: integer): double;
234 + var rValue: extended;
235   begin
236 <  Result := aValue * IntPower(10,aScale);
236 >  rValue := aValue;
237 >  Result := rValue * IntPower(10,aScale);
238   end;
239  
240   function SafeSmallInt(aValue: Int64): Smallint;
# Line 256 | Line 258 | end;
258   {AdjustScale returns a raw int64 value derived from x but with aNewScale}
259  
260   function AdjustScale(x: IFBNumeric; aNewScale: integer): int64;
259 var rValue: double;
261   begin
262 <  rValue := x.getrawValue;
263 <  Result := Round(rValue * IntPower(10,x.getScale-aNewScale));
262 >  Result := x.getRawValue;
263 >  aNewScale := x.getScale - aNewScale;
264 >  while aNewScale < 0 do
265 >  begin
266 >    Result := Round(Result / 10);
267 >    Inc(aNewScale);
268 >  end;
269 >  while aNewScale > 0 do
270 >  begin
271 >    Result := Result * 10;
272 >    Dec(aNewScale);
273 >  end;
274   end;
275  
276   function CompareInt(a,b: integer): integer;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines