1. Maths Functions

I have been looking for maths functions equivalent to the Basic
Round(x,no of places)
RoundUp
RoundDown

I didn't see them on the web site. Did I miss them or will I write my 
own?

Regards, Chris
structuraldzine at aol.com

new topic     » topic index » view message » categorize

2. Re: Maths Functions

Hi Chris,

try these....

function RoundDown(atom a)
    return floor(a)
end function

function RoundUp(atom a)
    if integer(a) then
        return a
    else
        return floor(a + 1)
    end if
end function

function Round(atom a, integer places)
    return floor(a * power(10, places) + 0.5) * power(10, -places)
end function

----- Original Message ----- 
From: "Structural D-zine" <structuraldzine at hotmail.com>
To: "EUforum" <EUforum at topica.com>
Sent: Friday, July 20, 2001 7:51 PM
Subject: Maths Functions

> I have been looking for maths functions equivalent to the Basic
> Round(x,no of places)
> RoundUp
> RoundDown
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: Maths Functions

Derek:
A generalization and a slight improvement for your routines:

function RoundDown(object a)
    return floor(a)
end function

function RoundUp(object a)
    return -floor(-a)
end function

function Round(object a,integer places)
    return floor(a*power(10,places)+0.5)*power(10,-places)
end function

Anyway, for routine Round, the results might not be accurate to 'places'
decimals, due to a small fuzz caused by binary versus decimal arithmetic, so
that if many figures are used for accounting purposes and added up, a
difference of a few cents might crop up. The only solution I know for this
problem is to work internally with cents instead of dollars and show the
results scaled.

----- Original Message -----
From: "Derek Parnell" <ddparnell at bigpond.com>
To: "EUforum" <EUforum at topica.com>
Sent: Friday, July 20, 2001 8:10 AM
Subject: Re: Maths Functions


>
>
> Hi Chris,
>
> try these....
>
> function RoundDown(atom a)
>     return floor(a)
> end function
>
> function RoundUp(atom a)
>     if integer(a) then
>         return a
>     else
>         return floor(a + 1)
>     end if
> end function
>
> function Round(atom a, integer places)
>     return floor(a * power(10, places) + 0.5) * power(10, -places)
> end function
>
> ----- Original Message -----
> From: "Structural D-zine" <structuraldzine at hotmail.com>
> To: "EUforum" <EUforum at topica.com>
> Sent: Friday, July 20, 2001 7:51 PM
> Subject: Maths Functions
>
> > I have been looking for maths functions equivalent to the Basic
> > Round(x,no of places)
> > RoundUp
> > RoundDown
> >
>
>
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: Maths Functions

On Wednesday 25 July 2001 07:23, Structural D-zine wrote:

> I couldn't find "!=" documented anywhere but found it appears to work as
> "not equal to". Is this correct?

See Refman2.html.

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu