dbTalk Databases Forums  

Can someone explain CAST(eExp as Numeric) to me?

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss Can someone explain CAST(eExp as Numeric) to me? in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Pedro Alves
 
Posts: n/a

Default Can someone explain CAST(eExp as Numeric) to me? - 03-29-2005 , 03:15 PM






Hi all,

Could someone explain me why CAST() keeps the full precision in the
variable although I tell him not to?

Example:

SET DECIMALS TO 3

d1 = 12.111 && store with decimal

d2 = CAST(d1 as Numeric(8, 1)) && should remove decimal
d3 = TRANSFORM(d2) && ok decimal gone
d4 = TRANSFORM(d2, "") && decimal again????

WAIT WINDOW d1 && 12,111
WAIT WINDOW d2 && 12,1
WAIT WINDOW d3 && 12,1
WAIT WINDOW d4 && 12,111 && <-- ???????????????

Shoudn't d4 be 12,100 ?

* I can get rid of the decimal part with:
d5 = VAL(TRANSFORM(d2))
d6 = TRANSFORM(d5, "")

WAIT WINDOW d5 && 12,100
WAIT WINDOW d6 && 12,100

ROUND() can't specify the number of digits to the left of the decimal
point, so it's not what I want.

Thanks in advance,

Pedro Alves

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.