Вопрос о математике в C или Objective C

CUDA теперь поддерживает printf прямо в ядре. Формальное описание см. В Приложении B.16 Руководства по программированию CUDA C .

6
задан Xcoder 17 June 2009 в 03:47
поделиться

1 ответ

Your code is wrong in objective C...

(200 / 23) * abs(2987 % 23) - (23 / 2);

Should be

(200 / 23) * abs((2987 % 23) - (23 / 2));

Which is just 73.9.

But this formula is also incorrect, you want values between 0 and 100. Your current formula does not reach 0, because a%23 has a range of 0-22, so the lowest value you can get if you subtract 23/2 and then take the absolute value is .5 (11-11.5 and 12-11.5). 22 would be the ideal number in this instance.

Also by subtracting 23/2 you get an uneven distribution, if you just multiplied the mod by 100/22, you would be better off. It would help to know what you are attempting.

17
ответ дан 8 December 2019 в 13:48
поделиться
Другие вопросы по тегам:

Похожие вопросы: