Thread: scale and Offsetting 15 - 0 to 0 - 1

  1. #1
    Registered User Fauveboy's Avatar
    Join Date
    Apr 2014
    Posts
    42

    scale and Offsetting 15 - 0 to 0 - 1

    I understand how to scale and offset values such as 0 - 3000 you can take to * 0.09 + 0.01. But is it possible to have values going from 15 - 8 and use same basic math to scale that to 0 - 1?

    Many thanks


    Joel

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,758
    It's something like:

    to scale x in the range A to B => range C to D

    Maybe this
    ( x - A ) / (B - A) * (D - C) + C

    It's just algebra, you should be able to check.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The Scale of the Universe
    By Mario F. in forum General Discussions
    Replies: 27
    Last Post: 02-06-2013, 02:55 AM
  2. File I/O: Offsetting file pointer (fp) using fseek
    By yesyesyes in forum C Programming
    Replies: 5
    Last Post: 03-21-2011, 05:33 PM
  3. Offsetting a pointer
    By gmrobert in forum C Programming
    Replies: 16
    Last Post: 08-30-2007, 08:28 PM
  4. Scale a picture
    By VOX in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 12-05-2004, 09:54 AM
  5. What is the IQ scale?
    By Shadow12345 in forum A Brief History of Cprogramming.com
    Replies: 19
    Last Post: 08-23-2002, 03:51 AM

Tags for this Thread