Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Currency data type, BUG or FEATURE?
Message
From
10/03/2006 20:21:05
 
 
To
10/03/2006 13:50:23
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01102959
Message ID:
01103334
Views:
15
Dragan, I have performed several naive test and have found the following:

1st Fastest time: ALL fields are double. Average time to complete the test: 6.15
2nd fastest time: there are mixed Double and Currency, but all currency are converted to double with MTON(). Average time: 6.25
3rd fastest time: all fields are currency. Average time: 7.5
4th fastest time: Currency and Double fields are mixed and not casted nor converted. Average time: 8.6
5th fastest time: Currency and Double fields are mixed, and currency is CAST() to double. Average time: 9.25
6th fastest time: all fields are Float. Average time: 9.7
Slowest time: all fields are converted to currency with NTOM(). Average time: 11.8

So the fastest seems to have all fields as doubles. Food for thought.

>>So are ther any advantages in using currency as a data type, instead numeric or double? Apart from output format with the currency sign?
>
>Internally, a currency value is a 64-bit integer which just gets divided by 10000 when used. So any computation with it should be a lot faster than the usual IEEE format floating numbers. It's perfect for financial apps where you may have a long computation.
>
>Other than that - you may need to check your computation for potential errors; when computing anything that includes division by numbers between -1 and 1 you may be better off by using regular IEEE numbers - they may not be as fast, but they maintain a 15 digits mantissa. If you're not sure when and where will VFP internally convert from currency to IEEE and back, you may consider using ntom() and mton() functions to enforce your own order.
>
>BTW, just heard your new president on the radio. She surely sounds good.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform