Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to typecase a numeric type
Message
From
19/07/1997 08:08:04
 
 
To
18/07/1997 23:01:16
Shihchau Tai
Apic Systems Pte Ltd
Singapore, Singapore
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00040343
Message ID:
00040730
Views:
32
Shih,

I don't know! I can only *guess* that it might make a difference to put the recommended added expression within parentheses.
I have had success with this with character fields and with smaller numbers, but no experience with the condition you describe.

Good luck,
Jim N

>Hi! Tai is my family name and Shih Chau is my given name.
>
>Well, if my applied is N(9,2), my discount is N(7,2), my allownce is N(7,2). SUM(applied+discount+allownce) gives N(16,2). However if I do SUM(applied+discount+allownce)*1000000.00/1000000.00, the result is N(30,4). I will never be able to get N(9,2).
>
>Did I misinteprete your message?
>
>Tai
>
>>Shih (or is it Tai?)
>>
>>Yes, there was a reason - you specified exactly N(9,2), and to assure exactly that the suggestion given is needed.
>>
>>regards,
>>Jim N
>>
>>>It works. Thx.
>>>
>>>In fact, I just multiply by 1 at both the SELECT and it works. Any reason for multiplying and dividing the big number. It seems to make the field big.
>>>
>>>
>>>Tai SC
>>>
>>>>>I am using FPW26. I am trying to UNION two select statement. The SELECT statement looks like the following:
>>>>>
>>>>>SELECT a.doc_no, doc_date, SUM(apply+discount+miscellaneous) AS problem;
>>>>> from a, b ;
>>>>> where a,doc=b.doc ;
>>>>>UNION ;
>>>>>SELECT a.doc, doc_date, doc_amt ;
>>>>> from a ;
>>>>> where .......
>>>>>
>>>>>
>>>>>Anybody can tell me how I can force the SUM() type to be the Numeric size I want. apply is N(9,2). discount is N(7,2), miscellaneous is N(7,2), problem ended up as N(16,2) and my doc_amt is N(9,2). How to force problem to be N(9,2)?
>>>>>
>>>>>
>>>>>Tai SC
>>>>
>>>>You are so right this silly behaviour. A silly but working suggestion is here :
>>>>SELECT a.doc_no, doc_date, SUM(apply+discount+miscellaneous) * 1000000.00/1000000.00 AS problem;
>>>> from a, b ;
>>>> where a,doc=b.doc ;
>>>>UNION ;
>>>>SELECT a.doc, doc_date, doc_amt* 1000000.00/1000000.00 ;
>>>> from a ;
>>>> where .......
>>>>
>>>>Cetin
Previous
Reply
Map
View

Click here to load this message in the networking platform