我想將我的浮點值轉換爲整數,但我無法將其轉換。它說不能找到符號。有沒有辦法做到這一點。Java數學轉換爲整數
這是我的Java代碼:
float upper = 999999;
float lower = 100000;
Integer ReceiptNo = 0;
Random rnd = new Random();
ReceiptNo = Math.round((Math.floor((upper - lower + 1) * rnd()))) + lower;
這是我的VB代碼:
Dim upper As Single = 999999 'Set the upper limit of random number.
Dim lower As Single = 100000
Dim ReceiptNo As Integer = 0
Randomize() 'Need to randomise the random number or else the number generated is always the same
ReceiptNo = CInt(Math.Floor((upper - lower + 1) * Rnd())) + lower
我想重用在Java VB代碼。謝謝。
見我的回答對VB,注意上是唯一的,因此需要在1以上的最大值。 – dbasnett