Click here to Skip to main content
15,890,506 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionRe: How to find the values of x and y in a 90 degree sector Pin
CPallini22-Jul-08 22:40
mveCPallini22-Jul-08 22:40 
AnswerRe: How to find the values of x and y in a 90 degree sector Pin
pallaka22-Jul-08 22:44
pallaka22-Jul-08 22:44 
GeneralYou're welcome Pin
CPallini22-Jul-08 22:50
mveCPallini22-Jul-08 22:50 
GeneralRe: How to find the values of x and y in a 90 degree sector Pin
pallaka22-Jul-08 22:33
pallaka22-Jul-08 22:33 
QuestionUnicode to html Pin
michela21-Jul-08 0:36
michela21-Jul-08 0:36 
AnswerRe: Unicode to html Pin
Paul Conrad21-Jul-08 4:20
professionalPaul Conrad21-Jul-08 4:20 
AnswerRe: Unicode to html Pin
dojohansen22-Jul-08 22:09
dojohansen22-Jul-08 22:09 
QuestionWrap values with upper and lower bound? [modified] Pin
Thrash50520-Jul-08 11:08
Thrash50520-Jul-08 11:08 
I've created a wrapvalue function in C#, but I can't figure out how to make it work with a lower bound, like a negative.

Here's the function at the moment:
private int WrapValue( int val, int upperBound ) {
    return val - ( upperBound * ( val / upperBound ) );
}


WrapValue( 1023, 360 ) would return 303.
By the way ( val / upperBound ) is integer division.

It works great for positive values, but not negatives and you can't specify a lower bound. Does anyone know how I to make it work with negatives and a lower bound so I could do something like this:

WrapValue( int val, int lowerBound, int upperBound )
WrapValue( -300, -500, 123 )

Thanks in advance.

By the way I'm using this to scroll a semi-transparent image over another image in the shape of a circle to create the illusion of a rotating sphere. The semi-transparent image needs to wrap around in a certain way and this function will help me accomplish that if I can get working correctly.

modified on Sunday, July 20, 2008 5:19 PM

AnswerRe: Wrap values with upper and lower bound? [modified] Pin
Luc Pattyn20-Jul-08 11:31
sitebuilderLuc Pattyn20-Jul-08 11:31 
GeneralRe: Wrap values with upper and lower bound? Pin
Thrash50520-Jul-08 11:55
Thrash50520-Jul-08 11:55 
GeneralRe: Wrap values with upper and lower bound? Pin
Luc Pattyn20-Jul-08 12:01
sitebuilderLuc Pattyn20-Jul-08 12:01 
GeneralRe: Wrap values with upper and lower bound? Pin
Thrash50520-Jul-08 12:14
Thrash50520-Jul-08 12:14 
GeneralRe: Wrap values with upper and lower bound? Pin
Luc Pattyn20-Jul-08 12:26
sitebuilderLuc Pattyn20-Jul-08 12:26 
GeneralRe: Wrap values with upper and lower bound? Pin
Thrash50520-Jul-08 12:34
Thrash50520-Jul-08 12:34 
GeneralRe: Wrap values with upper and lower bound? Pin
Luc Pattyn20-Jul-08 12:45
sitebuilderLuc Pattyn20-Jul-08 12:45 
GeneralRe: Wrap values with upper and lower bound? Pin
Thrash50520-Jul-08 12:57
Thrash50520-Jul-08 12:57 
QuestionPostfix Multidigit Expression Evation in C# Pin
sadiyaVasanthKumar18-Jul-08 22:09
sadiyaVasanthKumar18-Jul-08 22:09 
AnswerRe: Postfix Multidigit Expression Evaluation in C# Pin
cp987619-Jul-08 2:17
cp987619-Jul-08 2:17 
GeneralRe: Postfix Multidigit Expression Evaluation in C# Pin
Luc Pattyn19-Jul-08 2:22
sitebuilderLuc Pattyn19-Jul-08 2:22 
GeneralRe: Postfix Multidigit Expression Evaluation in C# Pin
Paul Conrad19-Jul-08 11:01
professionalPaul Conrad19-Jul-08 11:01 
QuestionConvert a value in one number range to a value in another number range? Pin
Thrash50513-Jul-08 13:23
Thrash50513-Jul-08 13:23 
AnswerRe: Convert a value in one number range to a value in another number range? Pin
Luc Pattyn13-Jul-08 13:24
sitebuilderLuc Pattyn13-Jul-08 13:24 
GeneralRe: Convert a value in one number range to a value in another number range? Pin
Thrash50513-Jul-08 13:42
Thrash50513-Jul-08 13:42 
GeneralRe: Convert a value in one number range to a value in another number range? Pin
Luc Pattyn13-Jul-08 14:10
sitebuilderLuc Pattyn13-Jul-08 14:10 
AnswerRe: Convert a value in one number range to a value in another number range? Pin
Nelek14-Jul-08 21:37
protectorNelek14-Jul-08 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.