0

I see the following code in an NVidia matrix program and a program from my instructor. When I look at this code I know I am doing something stupid, so could someone please explain to me what I am doing wrong? When I change the rand to a constant all I see is 0 for data[i], and when I try to view rand I seem to see only about 4 different values.

void randomInit(float* data, int size)  
{  
   for (int i = 0; i < size; ++i) {  
   data[i] = 1;//rand() / (float)RAND_MAX;  
   printf("%d %d\n",i, data[i]);  
  }  
}

Thank you for any help.

4

1 回答 1

0

%d打印格式化整数,尝试将其更改为%f. 这是其他 printf 代码。

于 2012-10-15T03:21:13.350 回答