Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Default decimal places
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Default decimal places

 Post Reply Post Reply
Author
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Topic: Default decimal places
    Posted: 20 March 2005 at 7:17pm
Is there any way to get asp to stop rounding automatically? I know i can do a formatnumber(1.22, 2) so that it has the correct number of decimal places, but I don't want to have to write a format number for every single number in my code. Aside from anything else, I don't want my 2's to display as 2.00 just so 1.22 displays as 1.22 instead of 1. Its also a bit of a pain in the neck when i'm trying to work with a db that has decimal values galore.
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 12:42am
ASP doesn't round automatically. If sounds like you you have a number conversion porblem with doubles changes to integer values.
Back to Top
Demon View Drop Down
Mod Builder Group
Mod Builder Group
Avatar
Mod-n-Skin Moderator

Joined: 26 July 2003
Status: Offline
Points: 299
Post Options Post Options   Thanks (0) Thanks(0)   Quote Demon Quote  Post ReplyReply Direct Link To This Post Posted: 21 March 2005 at 1:55am
Try making a custom sub like this:

Sub rInt(iNumber,iDecs)
    'Check if the number is a Whole Number or a Decimal
    If FormatNumber(iNumber,iDecs) > FormatNumber(iNumber,0) AND FormatNumber(iNumber,iDecs) < (FormatNumber(iNumber,0)+1) Then
        rInt = FormatNumber(iNumber,iDecs)
    Else
        rInt = Fix(iNumber)
    End If
End Sub


Then all you have to do is call it by using it like: rInt(1.22,2)
There for rInt(2.00000,2) and rInt(2.000011,2) would give out 2
But rInt(2.0109,2) would give out 2.01 because 2 decimal places back is a nonZero number. Respectively, rInt(2.000312,4) would give 2.0003.
So Sayith the Demon.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.