Re: access 97 floor function
From: Gary Walter (garylwpleasenospam_at_wamego.net)
Date: 04/21/04
- Next message: Noel: "Re: Repost.. Using Just Yearear in criteria for Long Date Field"
- Previous message: Loon: "criteria in cross-tab query"
- In reply to: MGFoster: "Re: access 97 floor function"
- Next in thread: Gary Walter: "Re: access 97 floor function"
- Reply: Gary Walter: "Re: access 97 floor function"
- Reply: MGFoster: "Re: access 97 floor function"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Apr 2004 06:00:56 -0500
Just for the record (and meaning no offense),
Works:
--------------
? (int(12.1234 / .1) * .1)
12.1
? (int(12.1799 / .1) * .1)
12.1
Unexpected Results:
---------------------
? (int(12.0 / .1) * .1)
11.9
? (int(12.0000000000000001 /.1) * .1)
11.9
One option (for Access versions that support CDec()):
------------------------------------------------------
? (int(CDec(12.0) /CDec(.1)) * CDec(.1))
12
? (int(CDec(12.0000000000000001) /CDec(.1)) * CDec(.1))
12
You may only need to use CDec in division
? (int(CDec(12.1234) /CDec(.1)) * .1)
12.1
? (int(CDec(12.199999) /CDec(.1)) * .1)
12.1
? (int(CDec(12.09999) /CDec(.1)) * .1)
12
? (int(CDec(12.0000000000000001) /CDec(.1)) * .1)
12
but you might use var in FLOOR function
to change Precision to Dec, then could use
var in both places.
I believe it is only the division and subtraction
of non-integers where this is a problem. To make
sure I'm not wrong, it would not hurt to read:
When Access Math Doesn't Add Up
by Luke Chung President of FMS
http://www.fmsinc.com/tpapers/math/index.html
Again, meaning no offense.
Gary Walter
"MGFoster" <me@privacy.com> wrote in message
news:QShhc.2674$eZ5.1684@newsread1.news.pas.earthlink.net...
> Marv wrote:
>
> > Can I duplicate the floor function in Excel in Access 97?
> > I need to round down to the nearest tenth.
> > example 12.1234 to 12.1
> > 12.1799 to 12.1
>
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> This is a function I obtained from MS's NeatCode97.mdb example file:
>
> Function Floor(N, ByVal Precision)
> '
> ' Similar to Excel's Floor function
> ' Rounds down (toward zero) to the next higher level of precision.
> ' Precision cannot be 0.
> '
> Precision = Abs(Precision)
> Floor = Int(N / Precision) * Precision
> End Function
>
> --
> MGFoster:::mgf00 <at> earthlink <decimal-point> net
> Oakland, CA (USA)
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP for Personal Privacy 5.0
> Charset: noconv
>
> iQA/AwUBQIWqN4echKqOuFEgEQK4RgCdFM+GyrKQCNAdVpjoa4U8KFLi3A0AoKl0
> Vi461d0dg0fcAFg+mt4nBZ+G
> =UXYH
> -----END PGP SIGNATURE-----
>
- Next message: Noel: "Re: Repost.. Using Just Yearear in criteria for Long Date Field"
- Previous message: Loon: "criteria in cross-tab query"
- In reply to: MGFoster: "Re: access 97 floor function"
- Next in thread: Gary Walter: "Re: access 97 floor function"
- Reply: Gary Walter: "Re: access 97 floor function"
- Reply: MGFoster: "Re: access 97 floor function"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|