当前位置: 动力学知识库 > 问答 > 编程问答 >

axapta - What is the algorithm for random numbers in X++? [AX]

问题描述:

What is the algorithm to have random reals using x++ in Dynamics AX?

网友答案:

The old way (and only if using Axapta 3.0) is to use the Random class which is listed in the AOT under System Documentation\Classes. It will return a 15 bit integer only. See AX Daily.

But like Alex, I will prefer using the newer xGlobal::randomPositiveInt32().

dice = (xGlobal::randomPositiveInt32() mod 6) + 1;
网友答案:

You can easily generate a positive int with this method, then just turn it into a real and divide after if you want decimals.

i = xGlobal::randomPositiveInt32();

分享给朋友:
您可能感兴趣的文章:
随机阅读: