Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / some math help. please

Author
Message
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 26th Apr 2010 12:25 Edited at: 26th Apr 2010 13:37
sorry to ask, I'm having a brain fart. I've done this before, but, can't remember how or what the equation is called.
Anyway, say I have a range of numbers, from 0 to 65535, and I want to convert them to normals type numbers, -1 to +1.
Can anyone help me with a formula to convert it?

ok, I think I got it figured it out
(value - (.5 * maxrange)) / (.5 * maxrange)
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 26th Apr 2010 20:18
or:
((2*Value)/MaxRange)-0.5

or:
(Value/(0.5*MaxRange)-0.5 if you can't store numbers greater than 65535

Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 26th Apr 2010 21:16
@kira
I like yours better, but its returning -.5 to 1.5.
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 26th Apr 2010 21:33
*facepalm*

((2.0*Value)/MaxRange)-1.0

Sorry

Login to post a reply

Server time is: 2026-07-26 04:28:06
Your offset time is: 2026-07-26 04:28:06