Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re[2]: Uniface Rounding.

135 views
Skip to first unread message

Merkel...@uniface.nl

unread,
Jan 16, 1996, 3:00:00 AM1/16/96
to
A solution similar to Joes ones (allowing even negative factors):
just the fake is different by using a bit of string-tricks

$10 = NUM1 ; INPUT NUMBER (Type = FLOAT)
$11 = RFACT ; ROUND FAKTOR
$12 = "" ; Rounded result (should be type FLOAT)

; the following lines will emulate the power-function y=10**x
if ($11 > 0)
$1 = "000000000000000000000000000000"[1:$11]
$1 = $number("1%%$1")
else
$2 = 0 - $11
$1 = "000000000000000000000000000000"[1:$2]
$1 = $number("1%%$1")
$1 = 1 / $1
$2 = ""
endif
; now solve x1 = x[round,n] as x1=( (x*10**n)[round,0] / 10**n)
$12 = $10 * $1
$12 = $12[ROUND]
$12 = $12 / $1
$1 = ""

**************************************************
* Ulrich Merkel ############### *
* Compuware System Software GmbH ############### *
* An der Trift 65 ###...###...### *
* D - 63303 Dreieich, Germany ###...###...### *
* +49 (0)6103 9488 - 0 ###.........### *
* Merkel...@uniface.nl ###.........### *
* *
* These ideas are my own ones, not COMPUWARE's *
**************************************************

______________________________ Reply Separator ____________________________
Date: 16.01.1996 19:51
Date: Tue, 16 Jan 1996 07:09:13 -0800
From: Joe Matuscak <matu...@rohrer.com>
To: merkel...@uniface.nl
Subject: Re: Uniface Rounding.

On Tue, 16 Jan 1996 CRO...@ocu.a1.ornl.gov wrote:

> I would like to do something similar to the following in my proc code:
>
> $1 = 123.4567
> $2 = 3
>
> $3 = $1[round,$2]
>
> PROBLEM! Uniface will not accept the last statement so I must substitute
> something like this for the last statement:

I dont think they slipped in an exponentiation operator into the 6 proc
language, but something along this line should work:

$loop$ = 1
$multiplier$ = 1

While $loop$ < $2 ;Fake a 10**n function
$multiplier$ = $multiplier * 10
$loop$ = $loop$ + 1
EndWhile

$1 = $1 * $multipler$
$1 = $1[round]
$1 = $1 / $multipler$


This should work for reasonable values of $2. FWIW, I didnt think Uniface
had a datatype that would cope with 999 decimal places. You may want to
define intermediate variables that are some sort of extended precision
floating point type to avoid rounding problems.


Joe Matuscak
Rohrer Corporation
717 Seville Road
Wadsworth, Ohio 44281
(216)335-1541
Matu...@Rohrer.com


0 new messages