convert 0-200 to 0-1 in csharp

To convert a value ranging from 0 to 200 to a value ranging from 0 to 1 in C#, you can use the following formula:

main.cs
double normalizedValue = originalValue / 200.0;
48 chars
2 lines

Where originalValue is the value ranging from 0 to 200 that you want to convert, and normalizedValue is the resulting value ranging from 0 to 1.

Here's an example code snippet that uses this formula:

main.cs
double originalValue = 100;
double normalizedValue = originalValue / 200.0;
Console.WriteLine(normalizedValue); // Output: 0.5
127 chars
4 lines

Note that you might want to use a different scaling factor if your original value range is different. For example, if the original value ranges from 0 to 100, you would use originalValue / 100.0 instead of originalValue / 200.0.

gistlibby LogSnag