Showing posts with label IT. Show all posts
Showing posts with label IT. Show all posts

Wednesday, November 21, 2007

Date And Time In Programming

Lars has published a great article about the difficulties with date and time programming.

Friday, November 09, 2007

Vista takes 100+ YearsTo Copy Files

Marco Cantu has posted about Vista prediciting it will take over 100 years to copy some files.

Personally, I can't wait that long.

Sunday, October 14, 2007

Implementing a Partial Serial Number Verification System in Delphi

Brandon Staggs has posted a excellent blog on writing a serial number verification system using Delphi.

The great thing is the techniques described can be applied to any language.

Sunday, April 01, 2007

Calculating Discounts Part 2

I solved the problem in my Calculating Discounts post. Here is how it is done.
Variables
ItemPrice = 50.00
Discount = 14.49%

Calculate Discount Value (DisValue)
DisValue = ItemPrice * (Discount/100)
DisValue = 50.00 * (14.49/100)
DisValue = 50.00 * 0.1449
DisValue = 7.245

Calculate NewPrice
NewPrice = ItemPrice - DisValue
NewPrice = 50.00 - 7.245
NewPrice = 42.755

Round Down Values
NewPrice = 42.75
DisValue = 7.24
PriceDown = 49.99

Calculate CheckTotal
CheckTotal = NewPrice + DisValue
CheckTotal = 42.75 + 7.24
CheckTotal = 49.99

Calculate Missing Value
MissValue = ItemPrice - CheckTotal
MissValue = 50.00 - CheckTotal
MissValue = 0.01

Add Missing Discount
DisValue = DisValue + MissValue
DisValue = 7.25
Now the both the new price and the discount value will add up to the original price.

Sunday, February 25, 2007

Calculating Discounts

Today we found an interesting bug in the software when discounts are applied to the transaction.

Here is an example.
Variables
ItemPrice = 50.00
Discount = 14.49%

Calculate Discount Value (DisValue)
DisValue = ItemPrice * (Discount/100)
DisValue = 50.00 * (14.49/100)
DisValue = 50.00 * 0.1449
DisValue = 7.245

Calculate NewPrice
NewPrice = ItemPrice - DisValue
NewPrice = 50.00 - 7.245
NewPrice = 42.755
At this point we need to round the values, becuase prices have two decimal places. There are two options, we can either round the values up or down.
Round Up Values
NewPrice = 42.76
DisValue = 7.25
Total = 50.01 (1p over)

Round Down Values
NewPrice = 42.75
DisValue = 7.24
Total = 49.99 (1p under)
As you can see, when we add up the rounded totals, they do not match the original item price. So we need find a way to solve this problem.

Wednesday, February 21, 2007

Two Jobs

Yes I now have two jobs!

Mode is now its own company and I've just started part time in a support role. I may also do some occasional development work.

I don't know if I should revive my old blog.

Thursday, October 19, 2006

Prepare for Vista

Saw this excellent article in the Delphi newsgroups. It shows you how to get your Delphi applications ready for Windows Vista.

Sunday, October 08, 2006

Unique Numbers

In my last job, each till transaction required a unique number, because all sales where collected from the tills databases and stored in main server database.

The problem was when you had independent tills in a couple of branches, how do you generate unique numbers.

Our final solution was to use the date and time, prefixed by the branch and till id. EG: 0123320061008160000

If you need more than one record per second, you can add milliseconds to the transaction ID.

Tuesday, September 05, 2006

Turbo Editions Are Online!

The Turbo editions of the Borland Developer Studio are now officially available for download.

Official Download Sites

Get downloading now! ;o)

Monday, August 28, 2006

Free Virtualisation

Both Mircosoft and VMware have released free versions of their virtialisation software.

They can both be used for a number of tasks, including the development and testing of software, in an isolatated environment.

Virtual PC
VMware Server