We’re putting the final touches on our new badges platform. Badge issuance remains temporarily paused, but all completions are being recorded and will be fulfilled once the platform is live. Thank you for your patience.

Ansys Learning Forum Forums Discuss Simulation Photonics How to generate a random integer within a specified range? Reply To: How to generate a random integer within a specified range?

Kirill
Forum Moderator

Hello Subscriber,

1.       Consider using the following functions, which take a floating-point argument and return an integer: ceil (rounds up), floor (rounds down), and round (rounds to the nearest integer).

2.       The rand function itself can also return an integer directly when used with 3 arguments. Please check the linked documentation for details.

 

Additionally, you may find it helpful to review the Ansys Optics Scripting Language section, as well as the Ansys Lumerical Scripting Course.

 

Best regards,

Kirill