**1**

###
#1
Members - Reputation: **320**

Posted 18 October 2012 - 07:30 PM

In the complete method i return 'r' as a SV_Target, when i use the one that works the pixel is replaced by the values that 'r' has and when i use the one that doesnt the pixel mantains the same.

###
#2
Crossbones+ - Reputation: **8478**

Posted 18 October 2012 - 07:44 PM

Basically, what it does is it divides the two operands and returns the fractional part (which is always between 0 inclusive and 1 inclusive). In your case, since you are converting that to an int after, you will always get zero no matter what. Using your example, you will get 2.0f % 3.0f = Frac(2.0f / 3.0f) = Frac(0.666..) = 0.666... Truncated down to an integer, you get zero. Not two.

You want to use fmod instead, probably. Or work in sufficiently large integers instead of floating-point numbers.

**Edited by Bacterius, 18 October 2012 - 07:46 PM.**

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

- *Pessimal Algorithms and Simplexity Analysis*

###
#3
Members - Reputation: **320**

Posted 18 October 2012 - 08:01 PM

Cord() method didnt returned me 0.666 and 'r' was getting the value that i expected in the end of the method but in the end the pixel wasnt getting it, so it was impossible to me to get that mistake.

###
#4
Members - Reputation: **320**

Posted 18 October 2012 - 08:25 PM

**Edited by lomateron, 18 October 2012 - 08:33 PM.**

###
#5
Crossbones+ - Reputation: **8478**

Posted 18 October 2012 - 08:31 PM

[source lang="plain"]r.x = (uint(a) % 3) + frac(a);[/source]

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

- *Pessimal Algorithms and Simplexity Analysis*

###
#6
Members - Reputation: **320**

Posted 18 October 2012 - 08:39 PM

YESSS!!! it fianlly worked I used

(uint(a) % 3)

the thing was that 3 wasnt really 3 but another float variable so i used

(uint(a) % uint(f))

and it worked

**Edited by lomateron, 18 October 2012 - 08:40 PM.**

###
#7
Crossbones+ - Reputation: **8478**

Posted 18 October 2012 - 08:44 PM

Unsure why fmod didn't work, it should have. How did you use it?

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

- *Pessimal Algorithms and Simplexity Analysis*