Re: [runway-dev] How to compute power of a number in the specification language?

9 views
Skip to first unread message

Diego Ongaro

unread,
Nov 28, 2016, 8:50:37 PM11/28/16
to runwa...@googlegroups.com
Hi Akhil,

There's a built-in function pow(base, exp) for this. For example:

> var m : 0..7 = 3;
> var a : 1..256 = pow(2, m);
> print a;
8

Otherwise, I guess you could write a while loop :)

Best,
Diego

On Fri, Nov 25, 2016 at 10:45 PM, Akhil Dixit <akad...@ucsc.edu> wrote:
Hello,

I'm trying to write a model, and I need to compute power of an integer in that.
I want something like..

var a : 1..8 = 2^m; //where m is an integer

For example if 'm' is 3, I want variable 'a' to have a value 8, which is 2 to the power 3.
How do I do this?

Thanks

--
You received this message because you are subscribed to the Google Groups "runway-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to runway-dev+unsubscribe@googlegroups.com.
To post to this group, send email to runwa...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/runway-dev/2abc9f86-7035-44a5-9fa8-01e7bbe73b0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages