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

how do you truncate numbers?

2 views
Skip to first unread message

Jerry

unread,
Apr 23, 2001, 6:56:10 AM4/23/01
to
i'm goofing with a small db project for a few of my friends who play golf
and the formula for figuring handicaps includes one step that requires
truncating numbers to 1 decimal place. I have looked everywhere for a
trunc function but i can't seem to find a solution. I've tried multiplying
by 10 and taking the int portion then div by 10 but same number comes back
to the n-th decimal place... any ideas?

tia

jerry


Turtle

unread,
Apr 23, 2001, 7:26:15 AM4/23/01
to
Access stores decimal numbers to the "n-th" place.
I gather (hope) that the value returned was correct for further
calculations; you just didn't like the way it displayed.
You can display only the first decimal place by setting the format property
of the textbox you're using to Fixed and the decimals property to 1.

HTH
-Turtle

"Jerry" <gal...@n-jcenter.com> wrote in message
news:eTTE6.260775$3J6.17...@news2.aus1.giganews.com...

Terry Wickenden

unread,
Apr 23, 2001, 1:17:07 PM4/23/01
to
Jerry

I presume you are trying to calculate the starting handicap after somebody
has submitted 3 cards. The following should point you in the right direction

sngWork = CInt(sngWork / 3 * 10)
sngWork = sngWork / 10
If sngWork > 28 Then sngWork = 28

sngWork is the total of the 3 "corrected" cards

Hope this helps

--
Terry Wickenden

To gain access to my EMail remove access

RunCommand Constants www.tkwickenden.clara.net


"Jerry" <gal...@n-jcenter.com> wrote in message
news:eTTE6.260775$3J6.17...@news2.aus1.giganews.com...

Jerry

unread,
Apr 23, 2001, 7:37:20 PM4/23/01
to
Terry,
I actually have the latest 20 scores and all the different slopes and course
ratings. but my end product handicap (handicap index) came out as much as
1.5 strokes different from our club computer. The only reason i got
involved was (besides curiosity) that the club changed hdcp software which
only displays changes to our handicaps on a once a month basis. my group
always has played to the current handicap including up to the very last
round played. our old club computer did it this way.
and the group kinda adoped that method. (the new way is published by usga
as correct, but we like the old way)

Anyway there is one step in the formula that specifically sais take the
result to 1 decimal place 'dropping all further decimal places NOT
ROUNDING'. i suspect there could be a difference. if enough of these
happened to fall the wrong way!

thanks for your help,
i'm still noodling

jerry

"Terry Wickenden" <terence....@accessntlworld.com> wrote in message
news:6uZE6.2387$Tv2.2...@news6-win.server.ntlworld.com...

James

unread,
Apr 23, 2001, 9:59:06 PM4/23/01
to
if x is your number then:

x = Fix(x) + Fix(10 * (x - Fix(x))) / 10

"Jerry" <gal...@n-jcenter.com> wrote in message

news:Q03F6.12152$8j.14...@bin1.nnrp.aus1.giganews.com...

Terry Wickenden

unread,
Apr 24, 2001, 1:45:28 AM4/24/01
to
x = Fix(10 * x) / 10

will achieve the same thing

Use Fix if -3.451 should be -3.4. Use Int if it should be -3.5

--
Terry Wickenden

To gain access to my EMail remove access

RunCommand Constants www.tkwickenden.clara.net


"James" <nos...@attcanada.net> wrote in message
news:_65F6.21856$TW.1...@tor-nn1.netcom.ca...

Terry Wickenden

unread,
Apr 24, 2001, 1:48:27 AM4/24/01
to
Jerry

Not sure what you mean by slopes but you are aware that the standard scratch
score for a course can change dependent on the scores of the competitors
who have entered the competition. Also I seem to remember that for handicap
purposes scores are actually reduced to a maximum of par + 2 for any hole.

--
Terry Wickenden

To gain access to my EMail remove access

RunCommand Constants www.tkwickenden.clara.net


"Jerry" <gal...@n-jcenter.com> wrote in message

news:Q03F6.12152$8j.14...@bin1.nnrp.aus1.giganews.com...

Vincent Quesnoit

unread,
Apr 24, 2001, 4:35:59 AM4/24/01
to
The actual problem is that you probably use floating point numbers, these
numbers will not represent the decimal numbers exactly, but with a very small
difference.
The truncation strategy does not work well in that context because if one
decimal number is represented by a slightly lower number, truncation will go to
the next lower value. While the same operation on the decimal number would not
change the value.
You have two choices :
1- multiply every number by ten and take int() before you do any computation
2- use the currency format which represents decimal values up to four places
without the small offset brought in by floating point numbers.

HTH,
Vincent

Jerry a écrit :

Jerry

unread,
Apr 24, 2001, 7:53:24 AM4/24/01
to
thanks guys, i think we're on the right track now!

jerry


"Jerry" <gal...@n-jcenter.com> wrote in message
news:eTTE6.260775$3J6.17...@news2.aus1.giganews.com...

Clive Bolton

unread,
Apr 24, 2001, 4:24:35 PM4/24/01
to
3- Store as an integer, shifting the decimal point. (Long Int for me).
Calculate in integers and display with dp.

Clive

"Vincent Quesnoit"
<vincent....@evidian.earth.sun.milkyway.universe.com.invalid> wrote in
message
news:3AE53AEF...@evidian.earth.sun.milkyway.universe.com.invalid...

James

unread,
Apr 25, 2001, 11:56:34 PM4/25/01
to
uh....yeah <g>

"Terry Wickenden" <terence....@accessntlworld.com> wrote in message

news:2r8F6.4329$Tv2.5...@news6-win.server.ntlworld.com...

Jeff Stanford

unread,
Apr 26, 2001, 3:58:06 PM4/26/01
to
Well, you can query them to a field where the width is narrower than the
original.
??

"James" <nos...@attcanada.net> wrote in message
news:Y0NF6.22465$TW.1...@tor-nn1.netcom.ca...
0 new messages