Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Currency value is out of range
Message
From
14/02/2005 16:21:06
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
14/02/2005 13:08:30
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00986704
Message ID:
00986802
Views:
21
>I get this error when dividing a currency value by zero. A normal numeric value will return asterisks. Example:
>
>? 1/0   && prints asterisks
>? $1/0  && "Currency value is out of range" error
>
>
>Is there a setting that will make the currency values behave like normal numeric values? I am changing several of my fields from numeric to currency types, and bad data could cause some views with calculated fields (i.e. price/qty) to bomb.
>
>Thanks.

You can also get some other strange behavior with currency values. For example, one that caused me grief was more or less like this:

? round($1 * 0.12345, 3)

gives you 0.124, not 0.123. This is because the number is rounded twice - the first time, when converting to currency (or as the result of a calculation involving currency values).

In cases like these, it may help to convert to numeric, with mton(). (In the case you mentioned, this strategy would also give you an asterisk instead of an error.)

However, note that for additions and substractions, currency is MORE accurate, not less, than the standard floating-point numbers - provided 4 decimals is enough for your needs.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform