simple integer generation using java math classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • miroconnect
    New Member
    • Sep 2007
    • 1

    #1

    simple integer generation using java math classes

    I want to generate a integer which should be combination of 2 integer and one int
    and anytime I call generate it should generate same value for same input and for different combinations it should generate different value.
    for example I passed to the service two integers 24, 25 and one int 76
    assume it generated 242576

    I restart jvm call the service pass the same values mentioned above it should return me same output 242576.

    I want to do this using some math functionality not using string concatinating ?Any suggestions on acheiving this? any help is greatly appreciated.
    miro
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by miroconnect
    I want to generate a integer which should be combination of 2 integer and one int
    and anytime I call generate it should generate same value for same input and for different combinations it should generate different value.
    for example I passed to the service two integers 24, 25 and one int 76
    assume it generated 242576

    I restart jvm call the service pass the same values mentioned above it should return me same output 242576.

    I want to do this using some math functionality not using string concatinating ?Any suggestions on acheiving this? any help is greatly appreciated.
    miro
    Use while loops, multiplication, division and addition.
    [CODE=java]
    int a, b, c;
    // read the numbers
    int a2=a;
    while(a > 0)
    {
    a2 *= 10;
    a /= 10;
    }
    // and so on
    [/CODE](For a =3, that will give you 30, for a = 24, that will give you 2400, etc.)

    Comment

    Working...