Check for an Even number?

  • I have this:

    if (@currentBid - @NewBid) <> cast(@bidincrement as money)

    u can prolly figure it's for an auction. Well the way it works, if bid is 200, u can go up to 250 if @bidincrement is 50. But it won't let us go directly to 150 or 100...

    so how can i check for proper increments?

    pretty much i need to check if (@currentBid - @NewBid) / @bidincrement is a whole number

    how can i do that?

  • Use Modulo % it shows the remainder value in a division equation.

    Select 10 % 5

    Result

    0

    Select 10 % 4

    Result

    2

    if ((@currentBid - @NewBid) % @bidincrement) = 0

     

  • Thank you... I forgot about modulo existence

  • oh, how would I do that if originally @currentBid and @NewBid are data type 'money' and @bidincrement is 'varchar'

  • Just cast them explicitly to int. like:

     if (Cast (@currentBid - @NewBid as int) % Cast(@bidincrement as int)) = 0

     


    * Noel

  • won't work... i get an error... like data type int and convert type modulo...

    ok... let's try w/o modulo

    how can I do some sort of a INSTRING to cut numbers before '.'

    like let's say result is 125.0000 - how do i get those 0000?

    Pretty much I want a check on last 4 digits for example of result from division

  • Well, something like:

    myMoney = 125.0000

    set myCheck = select(myMoney - round(myMoney,0))

    if myCheck != 0

    begin

    'something

    end

Viewing 7 posts - 1 through 6 (of 6 total)

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