Subject: Re: [stella] Rounding with DASM? From: Adam Wozniak <adam@xxxxxxxxxxxxxxxx> Date: Wed, 1 Dec 2004 10:43:52 -0800 (PST) |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wed, 1 Dec 2004, Dennis Debro wrote: > [(3 * 256 / 16)* 6] / 5 > Is there a way for DASM to evaluate this as 58 instead of 57? I assume you're rounding to the nearest whole number... 5 isn't easily divisible by 2, so let's change your original equation by multiplying top and bottom by 2. [(3 * 256 / 16)* 6 * 2] / 10 Now, to get the rounding, add 5 (half your denominator) to the numerator before you divide: ([(3 * 256 / 16)* 6 * 2] + 5) / 10 This will get you rounded to the nearest whole number. In the general case... If you've got N/D and you want a rounded to the whole number result, compute (2*N+D) / (2*D) - -- adam@xxxxxxxxxxxxxxxx http://cuddlepuddle.org/~adam KG6GZR http://cuddlepuddle.org/~adam/resume.html "Feminist? Why would I want to alienate half the population? I'm an egalitarian." -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFBrhDkyvXf5Z0z5zERAg9mAJ9Ew+Tk3GqjueIsLnhMove+0vjrHwCgg6Pt /lqh9bTNKrTURJWTbfFMisM= =Vd/R -----END PGP SIGNATURE-----
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Rounding with DASM?, Dennis Debro | Thread | What is the purpose of address $288, Dennis Debro |
Re: [stella] Rounding with DASM?, Rob | Date | Re: [stella] Rounding with DASM?, Dennis Debro |
Month |