RSS Forums RSS
Please support our Computer Science and Software Design advertiser: Programming Forums

It's Alive!! Program with a mind of it's own....

Join Date: Jun 2004
Location: Worcester, Massachusetts
Posts: 180
Reputation: Toba is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 3
Toba's Avatar
Toba Toba is offline Offline
Junior Poster

Re: It's Alive!! Program with a mind of it's own....

  #8  
Jun 21st, 2004
Well, once I was working some a function that would return a string along the lines of : "This system has been running for 1 week, 3 days, 2 hours, 1 minute, 0 seconds."

I was doing this in VB and using a DLL to retrieve the TSC (Time Stamp Counter: contains the number of clock pulses since the comp was booted). It would divide by the clock freq. (unfortunately I had to hard-code this, I don't know how to get a real value) to get the number of seconds since reboot and then use the mod statement and some multiplication and division to come up with the string. All my variables were doubles (I want this thing to work even when the computer has been booted more than 10 minutes), but I was getting an overflow error when I did this:

dim weekDivider as Double
weekDivider = 7 * 24 * 60 * 60

I was up until 4:30 AM finding the bug. It turns out that when you do math on ordinal values, VB assumes that you're putting it in an Integer data type unless you put a pound sign after each of the numbers, like this:

weekDivider = 7# * 24# * 60# * 60#

I will never understand why VB does this...
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:29 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC