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; |
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; |