IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
  • 1.  % operator on Long variable

    Posted 10/31/07 09:56 PM

    Hi,

    I’m writing a java service to get the quotient value. I need to get the value of quotient = (dividend % 10000), dividend is 16 digits. when I try to compile it says “operator % cannot be applied to java.lang.Long,int”

    Can u guys help me out.

    Thanks & Regards,
    Rama


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 2.  RE: % operator on Long variable

    Posted 10/31/07 11:18 PM

    Can you please check if you have declared dividend as Long.

    Thanks,
    KVReddy


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 3.  RE: % operator on Long variable

    Posted 10/31/07 11:23 PM

    Quotient is the result of a division, which is the / operator.

    The % operator will give you the remainder (often incorrectly called the modulus or modulo).
    –Edit: [URL=“Classroom Resources - National Council of Teachers of Mathematics”]Classroom Resources - National Council of Teachers of Mathematics is a great thread on this explaining “The problem is that people tend to think of modulus as the same as remainder…” They are not.

    You cannot use operators with any Java object (except + for String objects). There are two approaches to fix your code:

    1. Don’t create a java.lang.Long object in the first place. Just create a long primitive.

    2. Get the long primitive from the Long object by calling the longValue() method. e.g. remainder = (dividend.longValue() % 10000)


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB