Generating Negative and Positive Numbers

2000's icon

Hello,

I'm trying to generate random numbers between -63 and 63, but can't work out how to adapt previous patches that have been submitted to the forum. Also, would it be possible to adapt the equation for variable arguments?

Thank you

schlam's icon

hello.
something like that ?


2000's icon

Hello,

Perfect.

Thank you very much

schlam's icon

you're welcome =)

Roman Thilenius's icon


2000 > 110

:(

Rick's icon

[expr random(-63,63)]

;D

2000's icon

Hello,

Thanks, also.

2000's icon

Hi Schlam,

Thanks a lot for the patch yesterday. It works great, but at the risk of sounding stupid, could I ask a question about its operation, please. I understand the addition of +1 to create the correct number for random, but why is the range 128? Is it because -63 becomes the equivalent of 0?

Thank you

schlam's icon

hello,
with 128, [random] will output randomned values from 0 to 127
with the [- 63] after, it will output from -63 to 64.
yes, for your request, random "127" would be more appropriate and will really output from -63 to 63

2000's icon

Hello,

Great. Thanks for clarifying.

Roman Thilenius's icon


the principle of "offset".

if you need to need to do something which only works in a certain number range, do e.g. +64, process, -64

2000's icon

Hello,

OK, thanks. I think I understand what you mean, but would it be possible to illustrate with a basic example using a couple of objects, just so I'm sure.

Thank you