Groups > Superbase > Superbase 3 programming > Re: Minus sign




Minus sign

Minus sign
Sun, 4 Mar 2007 12:13:51 -0000
I have a property management programme which, amongst other things, will 
generate a demand for outstanding rent etc. The demand is based on records 
where the amount paid is less than the amount due. Sometimes the report will 
include entries where the amount paid is the same as the amount due and it 
is displayed as "-£0.00". Does anyone have any ideas? 


Post Reply
Re: Minus sign
Mon, 05 Mar 2007 11:06:39 +000
Roger A. Wilkey wrote:
> I have a property management programme which, amongst other things, will 
> generate a demand for outstanding rent etc. The demand is based on records

> where the amount paid is less than the amount due. Sometimes the report
will 
> include entries where the amount paid is the same as the amount due and it

> is displayed as "-£0.00". Does anyone have any ideas? 
> 
> 
> 
This is a classic problem in dealing with decimal fractional values in a
computer and is caused by the fact that decimal fractional values cannot
map precisely to binary. The solution is to make sure that you use the
FIX() function in your calculations in order to force the values to chop
off the tiny fractional components that occur in the course of
calculations and storage in base 10.

Post Reply
Re: Minus sign
Mon, 05 Mar 2007 12:14:05 +010
Hallo

mostly such things occur due to rounding differences. So if you have a 
number coming out of a division, the value may differ slightly from the 
value displayed.
You normally don't see those things in Superbase, as the format of the 
numbers only is the format of the displayed value and not of the value 
kept in the database. So both values my differ.

To work around this i would suggest to change your queries to use a 
tolerance. E.a. changing from asking for x% > 0.0 to x% >= 0.01 or x%
<> 
0 to ABS(x%) >= 0.01 (or any other tolerance).

hope that helps

Gruß
Andreas K.


Roger A. Wilkey schrieb:
> I have a property management programme which, amongst other things, will 
> generate a demand for outstanding rent etc. The demand is based on records

> where the amount paid is less than the amount due. Sometimes the report
will 
> include entries where the amount paid is the same as the amount due and it

> is displayed as "-£0.00". Does anyone have any ideas? 
> 
> 
Post Reply
Re: Minus sign
Mon, 5 Mar 2007 19:42:28 -0000
Many thanks. I will give these suggestions a try.

"Andreas Knoblauch" <Andreas.Knoblauch@icem.com> wrote in
message 
news:esgtri$ggl$1@ipx22096.ipxserver.de...
> Hallo
>
> mostly such things occur due to rounding differences. So if you have a 
> number coming out of a division, the value may differ slightly from the 
> value displayed.
> You normally don't see those things in Superbase, as the format of the 
> numbers only is the format of the displayed value and not of the value 
> kept in the database. So both values my differ.
>
> To work around this i would suggest to change your queries to use a 
> tolerance. E.a. changing from asking for x% > 0.0 to x% >= 0.01 or x%
<> 0 
> to ABS(x%) >= 0.01 (or any other tolerance).
>
> hope that helps
>
> Gruß
> Andreas K.
>
>
> Roger A. Wilkey schrieb:
>> I have a property management programme which, amongst other things,
will 
>> generate a demand for outstanding rent etc. The demand is based on 
>> records where the amount paid is less than the amount due. Sometimes
the 
>> report will include entries where the amount paid is the same as the 
>> amount due and it is displayed as "-£0.00". Does anyone have
any ideas?
> 


Post Reply
Re: Minus sign
Mon, 05 Mar 2007 23:45:21 -050
Some functions I use for this kind of thing...

FUNCTION TotFx%(n%)
  TotFx% = funkNum%(n%,1)
  END FUNCTION

FUNCTION TotString$(n%)
  TotString$ = funk$(n%,1)
  END FUNCTION


FUNCTION funkNum%(n%,s%%)
  SELECT CASE s%%
  CASE 1:funkNum% = n%
  CASE 0:funkNum% = FIX (n%,2)
  CASE 2:funkNum% = Truncate%(n%)
  CASE 3:funkNum% = CurrencyRU%(n%)
  CASE 4:funkNum% = CurrencyRD%(n%)
  CASE 5:funkNum% = FIX (n%,4)
  END CASE
  END FUNCTION

FUNCTION funk$(n%,s%%)
  SELECT CASE s%%
  CASE 1:funk$ = LTRIM$ ( STR$ (n%))
  CASE 0:funk$ = LTRIM$ ( STR$ ( FIX (n%,2),"-,99999999.00"))
  CASE 2:funk$ = LTRIM$ ( STR$ (Truncate%(n%),"-,99999999.00"))
  CASE 3:funk$ = LTRIM$ ( STR$ (CurrencyRU%(n%),"-,99999999.00"))
  CASE 4:funk$ = LTRIM$ ( STR$ (CurrencyRD%(n%),"-,99999999.00"))
  CASE 5:funk$ = LTRIM$ ( STR$ ( FIX (n%,4)))
  END CASE
  END FUNCTION

FUNCTION CurrencyRU%(n%)
  CurrencyRU% = INT (( ABS (n%) + .005000001) * 100) / 100
  END FUNCTION

FUNCTION CurrencyRD%(n%)
  CurrencyRD% = INT (( ABS (n%) - .005000001) * 100) / 100
  END FUNCTION

FUNCTION Truncate%(n%)
  a$ = LTRIM$ ( STR$ ( ABS (n%)))
  rtdec$ = LTRIM$ ( MID$ (a$, INSTR (a$,"."),3))
  lfdec$ = LTRIM$ ( MID$ (a$,1, INSTR (a$,".") - 1))
  Truncate% = VAL (lfdec$ + rtdec$)
  END FUNCTION






On Mon, 05 Mar 2007 06:14:05 -0500, Andreas Knoblauch
<Andreas.Knoblauch@icem.com> wrote:

> Hallo
>
> mostly such things occur due to rounding differences. So if you have a
> number coming out of a division, the value may differ slightly from the
> value displayed.
> You normally don't see those things in Superbase, as the format of the
> numbers only is the format of the displayed value and not of the value
> kept in the database. So both values my differ.
>
> To work around this i would suggest to change your queries to use a
> tolerance. E.a. changing from asking for x% > 0.0 to x% >= 0.01 or x%
<>
> 0 to ABS(x%) >= 0.01 (or any other tolerance).
>
> hope that helps
>
> Gruß
> Andreas K.
>
>
> Roger A. Wilkey schrieb:
>> I have a property management programme which, amongst other things,
will
>> generate a demand for outstanding rent etc. The demand is based on
records
>> where the amount paid is less than the amount due. Sometimes the report
will
>> include entries where the amount paid is the same as the amount due and
it
>> is displayed as "-£0.00". Does anyone have any ideas?
>>
>>
>>
>
Post Reply
about | contact