Hi All, I am into Development and in one of my clients Requirment i want to generate 10 Digit RANDOM Numbers. That could be any number for Ex 0000000000 0101010101 But it should be RANDOM. I am aware about RANDOM and RANDOMIZE functions available for integer datatype. And i tried this Code also. It works but my client is not Happy about it. looking for alternative T:=0; WHILE T <> 5 DO BEGIN a := RANDOM(100000); IF a >= 10000 THEN BEGIN MESSAGE(’%1’,a); T := T + 1; END; END; Any Help would really be Appreciated!!!

Hi. Your sample looks like a binary number. Should the resulting Number be binary or can the digits take any value from 0 through 9? Anyway, have you tried to build you number from a sting value and from that string pick digit by digit and random that between the decired values?

Hey Steen, I have clearly mentioned that i want 10 digit Random Number. It has noting to do with Binary number. And this should be automatic. The starting number can be assigned but the rest of the 10 number which is of 10 digit should be automatic and random. And by codeunit only!!!

The max value you can put in an integer is 9 digits long. You will have to use a float to do want you want to do. Do not forget to use the RANDOMIZE function.

What do you mean with:

quote:

The starting number can be assigned

And why didn’t your client like what you did with RANDOM?

How about something like this: ` // Number and Number2 are Decimals, Factor is Integer. REPEAT //Create a random number RANDOMIZE; Number := RANDOM(1000000000); // Create a factor to multiply number with, because RANDOM can only handle Integers up to about 2.100.000.000 RANDOMIZE; Factor := RANDOM(10); // Add increment to resulting Number2 Number2 := Number2 + Factor * Number; // If Factor = 10 and RANDOM(Number)=1000000000 then a 11-digit-No (10.000.000.000) // would be the result. In this case reduce Number randomly IF Number > 9999999999 THEN Number := Number - RANDOM(10); // Make sure that Number2 has 10 digits UNTIL Number2 >= 1000000000; // Show me what you calculated :-): MESSAGE(FORMAT(Factor) + ' ' + FORMAT(Number2)); `

The numbers produced often start with 1… because of the algorithm, but this could be adjusted. The factor basically overcomes the problem with the 2-billion-something restriction on Integers. RANDOM does not function on BigIntegers unfortunately. Maybe a suggestion for MBS… What do you need the random no. for???

…and if somebody askes you to clarify your initial question, then normally just to be sure that he/she understands your problem… Your example 0000000000 0101010101 was also in my eyes rather misleading as this could easily binary numbers only… I would also rather ask back before elaborating a right solution for the wrong problem…

Maybe we can use this to build a complete Casino Management Add-On? Sorry for going off-topic, Ashok900… couldn’t resist it!

yeah, you should show the evens in red and the unevens in black. Or was it vice-versa?

Nelson, I’m pretty sure he is developing a Personel expense calculator. You the one where you enter $ required for reimbursment, and it scans the customer list compares location on map quest to miles/km, uses expedia to find hotel rates, then prints out a nice business expense claims form.[:D]

Thanks Beaver!!! You really deserves a Bouquet of flowers but i dont know your address otherwise i would have send it across. :)

Well, maybe one day I will visit India again…