Converting Negative to Positive: Transforming -1 to 1 into 0 to 1 in Java

  • Thread starter Thread starter bitttttor
  • Start date Start date
  • Tags Tags
    Change
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
bitttttor
Messages
11
Reaction score
0
Hi,
I'm making a small app in java and part of the script retrieves an 'evaluation' factor from 'a' between -1 to 1 (e.g. 0.882) where 1 is the best and -1 is the worst.
Now, my problem in that I need to change it into a positive factor form 'b' from 0 to 1 to compute with other factors. For example if the factor is a = 0, then b = 0.5
I cannot gasp the math.

Any help would be more than welcomed.

Best
 
Physics news on Phys.org
You can shift the interval [-1, 1] up to [0, 2] and then scale it.
 
CompuChip said:
You can shift the interval [-1, 1] up to [0, 2] and then scale it.

Thanks... I need some caffeine.
 
In my time zone it was 03:45 AM when you said that, so I'd say you need some sleep. But I guess caffeine will do too :)