floating nightmare

  • I have a number that is coming from a source where it passes the negative sign and I do not know offhand the size of the number but I know that the number should always come in with a total of 5 places to the right of a decimal place....

    IE 4.20000

     

    Because I do not know the ultimate size and because setting the table type as a float causes the number to round...IE 0.00013

    looks like 1.2999999999999999E-4

    I am intially setting it to a varchar.

    I ultimately need to be able to multiply the number by 1000 so I end up with a decimal place of 2. I can't cast on the varchar, I am getting an error

    IE select cast(amt as decimal (38, 5)) as amt will not let me convert the varchar to an int...Ultimately I just want to do the multiplication and then set it to a decimal. If anyone has a suggestion, I'd love to hear it...

  • I', a bit confused... you know the number should always come in having 5 decimal places but you want to convert VARCHAR to INT and you ultimately want to "do the multiplication and then set it to decimal"?  Can you clarifiy what the heck it is you really want to do, please?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply