Blitz (500/640)

From:Sami N��t�nen
Date:20 Sep 99 at 20:09:08
Subject:Re: Rounding amounts (fwd)

Oops sorry Rob forget to change the address ;)

*** Begin of forwarded message ***

Date: 20-Sep-99 22:07:39
From: Sami N��t�nen <sami.naatanen@dlc.fi>
Subject: Re: Rounding amounts

--- Forwarded message follows ---

On 19-Sep-99, Rob Hutchinson wrote.

> Hello Tony
>
>> I have a long variable containing the number of cents and need to
>> round so numbers ending in 3,4,5,6 or 7 are converted to end in 5, all
>> others are to end in zero (1,2 rounded down, 8 & 9 rounded up)
>>
>> any elegant ideas anyone?
>
> Right, attached is an extremely cut-down version of the MSDLib we are
> writing for our game.
>
> Pretty much all of the Rounding commands were done by David McMinn,
> I think I converted one, but he speeded it up and redid it..
>
> Anyway, the commands left in the lib are:
>
> N.w=MSDRound(Number,ClosestMultiple)
> N.w=MSDRoundUp(Number,ClosestMultiple)
> N.w=MSDRoundDown(Number,ClosestMultiple)
> N.q=MSDQRound(Number.q,ClosestMultiple.q)
> N.q=MSDQRoundUp(Number.q,ClosestMultiple.q)
> N.q=MSDQRoundDown(Number.q,ClosestMultiple.q)
>
> These should help you. Though they dont deal with longwords, sorry.
> The complete version has 45 useful commands and will be released
> after the game is complete.... MAYBE :)
>
> Lib Number 63
>
>> Thanks in advance
>
> Hope this helps you?
>

Well I think I have the best solution for this particular case

cents.l=(cents.l+2)/5*5

and voila it's done. :)



Sami N��t�nen
EMail: sami.naatanen@dlc.fi

*** End of forwarded message ***



Sami N��t�nen
EMail: sami.naatanen@dlc.fi

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie