SynthMaker

Code: pow with negative base does #IND

Archive · 2012 8 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

jacob ·

x = pow(-1,4);

Why does this code show me -1.#IND on the streamout? Instead of correct value -> 1.

CoreStyler ·

You will never get >4. At least you will get 4. To do a statement is better to use green data, and streambool out the result (0 is false, 1 is true). and -1 * -1 *-1 *-1 = 1.

jacob ·

CoreStyler wrote: You will never get >4. At least you will get 4. To do a statement is better to use green data, and streambool out the result (0 is false, 1 is true).

Sorry, that was wrong. I want 1 to come out and not the 4 I mentioned first.

CoreStyler ·

jacob wrote: CoreStyler wrote: You will never get >4. At least you will get 4. To do a statement is better to use green data, and streambool out the result (0 is false, 1 is true).

Sorry, that was wrong. I want 1 to come out and not the 4 I mentioned first.

Done. you want to have a negative phase?

To calculate: pow (-1,4) synthmaker not work (don't know why). But doing pow (1,4) * -1 does. 😉

And with your code you bypassed the input. So i addedd out = in + pow(1,4) * -1; instead of out = pow(1,4) * -1; Because you bypass the input that does not affect anything.

jacob ·

CoreStyler wrote: Done. you want to have a negative phase?

To calculate: pow (-1,4) synthmaker not work (don't know why). But doing pow (1,4) * -1 does. 😉

And with your code you bypassed the input. So i addedd out = in + pow(1,4) * -1; instead of out = pow(1,4) * -1; Because you bypass the input that does not affect anything.

Thank you for your very fast answers and the osm. but this is not what I was after. I want 1 be negative or positive depending on the exponent. So every even number (2,4,6,...) makes it positive: (-1)^4 = (-1)*(-1)*(-1)*(-1) = 1 And every uneven number (1,3,5,...) makes it negative: (-1)^3 = (-1)*(-1)*(-1) = -1

jacob ·

I solved it with another calculation. Dividing the variable by 2 and checking if it has decimal places - by checking it against the rounded value. But it would be better if the pow() would work.

martinvicanek ·

SM's implementation of pow() allows for non-integer exponents hence it expects a positive base to make sure that the result is a real (not a complex) number.

jacob ·

martinvicanek wrote: SM's implementation of pow() allows for non-integer exponents hence it expects a positive base to make sure that the result is a real (not a complex) number.

Thank you for this info.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.