rounding

Discuss anything related to using the program (eg. triggered betting tactics)

Moderator: 2020vision

rounding

Postby funky » Mon Apr 10, 2006 8:12 am

Has anyone else found some weird sh*t going on with rounding?

My excel app stakes less if the odds are higer, so obviously it has to divide one number with another to arrive at the stake.

Before my code writes this stake into Excel, I do a stake = round(stake,2)

So you'd expect to get a nice rounded stake like, say $6.80 - wouldn't you.
But no - not in Microsoft land. You may get something weird like $6.800000000235.
I've googled this and its something to do with microsoft using two different rounding algorithms.
I've even seen this when reading a value like (my default stake) of $6 out of my configuration page, and then vba posts it into the main page as $6.000009345. Weird.

Anyway - rant over. If you haven't seen it, be aware it may happen. And if you have seen it, apparently the way round it (pardon the pun....) is to use Stake = formatnumber(stake,2)
User avatar
funky
 
Posts: 33
Joined: Tue Feb 21, 2006 6:26 am
Location: Auckland, New Zealand

Postby allgreen » Mon Apr 10, 2006 12:01 pm

I just use INT function. Rounds down to whole number.
allgreen
 
Posts: 98
Joined: Wed Mar 08, 2006 7:28 am
Location: Down Under

Postby Captain Sensible » Mon Apr 10, 2006 5:00 pm

I use ROUNDUP

ROUNDUP(stake/O6,2)

Doesn't seem to give problems but I'm sure I changed from using ROUND because of the errors it was giving.
User avatar
Captain Sensible
 
Posts: 2883
Joined: Sat Nov 19, 2005 2:29 pm

Postby Mitch » Tue Apr 11, 2006 2:09 am

It's probably got nothing to do with it but interesting (to a geek like me anyway).

Excel doesn't think in decimal, it's binary. This means that certain decimal numbers, however easy you might think it should be, cannot be accurately held in memory.
It's easy to make an integer from binary, but a lot harder to make the fraction part when all you are allowed to add together to make it is 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, 1,128, 1/256, etc.

A good example is 0.1
It cannot be done 100% accurate in binary form (so I'm told) . :?
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby tkp » Thu Apr 13, 2006 9:41 pm

Captain Sensible
PostPosted: Mon Apr 10, 2006 4:00 pm Post subject:
I use ROUNDUP

ROUNDUP(stake/O6,2)

Doesn't seem to give problems but I'm sure I changed from using ROUND because of the errors it was giving.


Ditto that ....I have less problems with Roundup than with just plain old Round.


tkp
User avatar
tkp
 
Posts: 213
Joined: Fri Nov 18, 2005 8:41 pm
Location: Midlands

Postby funky » Thu Apr 13, 2006 10:31 pm

Ok thanks for that. will switch to roundup.
User avatar
funky
 
Posts: 33
Joined: Tue Feb 21, 2006 6:26 am
Location: Auckland, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 29 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.

cron