View previous topic :: View next topic
|
Author |
Message |
sudhaaa
New User
Joined: 24 Mar 2005 Posts: 51
|
|
|
|
Hi,
Can you please let me know how below expression will work
CHAR(SUM(INTEGER(DECIMAL((0.03*0.03),17,6)/DECIMAL((0.03*0.03),17,6)-0.001) )))
When I tried it is giving junk values... |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What are you trying to accomplish? |
|
Back to top |
|
|
sudhaaa
New User
Joined: 24 Mar 2005 Posts: 51
|
|
|
|
I need to fix above problem, which happend in live.
I treid with other values in place of 0.03 (with 126.25), where it is giving correct result
But when I tried with 0.03, it is giving junk values. Hence need to analyze on why it's giving junk values for 0.03 |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what exactly are these junk values? |
|
Back to top |
|
|
sudhaaa
New User
Joined: 24 Mar 2005 Posts: 51
|
|
|
|
I am really sorry to say, do you really need what junk values it is giving to explain above one |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I am ready to say that anyone who describes output from anything as 'JUNK' is in a really sorry situation. It appears that you don't know very much.
The sql contains no columns or host-variables. Why are you using all these column functions? integer, decimal etc. when you cast as integer, you lose your decimal positions (i.e. values between .999999999999999 and .0000000000001.
and the reason that I wanted to know what the 'junk' was, is that I understand what the computer does when it executes, thus I could have worked backwards to see why your results are different when you use a value greater than 1 (as apposed to less than 1).
but, you seem to know it all (instead of simply answering my question, you give me a BS response). hope someone else has patience and will help you.
have a good weekend. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
wow...
integer( (x*x) / ( (x*x) - 0.001)
wasting bandwitdh for a computation that will always yield a 0 or a 1
given the appropriate number of decimal digits
Quote: |
I am really sorry to say, do you really need what junk values it is giving to explain above one |
I agree that refusing to tell what the junk is he is safeguarding
confidential info
I would had done the same |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
what in the world could be confidential about this garbage or the 'output' of this SQL execution? It looks like to me that the sql is summing a bunch of integers.
Code: |
CHAR(SUM(INTEGER(DECIMAL((0.03*0.03),17,6)/DECIMAL((0.03*0.03),17,6)-0.001) )))
|
Code: |
CHAR(
SUM(
INTEGER(
DECIMAL(
(0.03*0.03),17,6
)
/
DECIMAL(
(0.03*0.03),17,6
)
-0.001
)
)
)
)
|
there are no host variables, there are no columns. The is nothing except literals and column functions.
There is no such thing as 'junk' as output. It may not be what 'you want', but the computer only does what you tell it to do by means of your code (be it JCL, cobol programs, SQL). The computer is not a person; it can not determine what you 'wanted' - only what you told it todo. So, since computers are predictable, you can trace a result backwards thru the code that was executed and determine the original input.
So, this silliness about confidential info does not apply here. And even if it did, the OP could have stated so instead of providing a childish response. |
|
Back to top |
|
|
sudhaaa
New User
Joined: 24 Mar 2005 Posts: 51
|
|
|
|
Thanks and Bye to this group |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Thanks and Bye to this group |
Thanks for what ?? |
|
Back to top |
|
|
|