Rounding decimals to ruler scale (log, pow math?)

  • I
  • Thread starter 1plus1is10
  • Start date
  • Tags
    Log Scale
In summary, the speaker needed help rounding data (all less than 1) to the nearest 1/2, 1/4, 1/8, 1/16, and 1/32. They were unsure of how to do this mathematically, but eventually figured it out using the functions pow and log. They discovered that rounding up the result of ln(x)/ln(0.5) and then using the pow function with 0.5 as the base would give them the desired result.
  • #1
1plus1is10
51
0
I have data (all less than 1) and I need to round down to the nearest 1/2, 1/4, 1/8, 1/16, and 1/32.
I have no idea how to do this mathematically, but I'm guessing I use log or pow functions.

For example:
0.81 = 0.5 or 1/2
0.33 = 0.25 or 1/4
0.18 = 0.125 or 1/8

Any help would be appreciated.
Thanks
 
Mathematics news on Phys.org
  • #2
1plus1is10 said:
I have data (all less than 1) and I need to round down to the nearest 1/2, 1/4, 1/8, 1/16, and 1/32.
I have no idea how to do this mathematically, but I'm guessing I use log or pow functions.

For example:
0.81 = 0.5 or 1/2
0.33 = 0.25 or 1/4
0.18 = 0.125 or 1/8

Any help would be appreciated.
Thanks
Are you looking for the mathematical functions and symbols to use, or for an algorithmic solution?
 
  • #3
1plus1is10 said:
I have data (all less than 1) and I need to round down to the nearest 1/2, 1/4, 1/8, 1/16, and 1/32.
What does this mean?
You can round down to the nearest 1/2 OR to the nearest 1/4 etc. You can't round to the nearest 1/16 AND 1/32, for example.
 
  • #4
Sorry for not knowing how to phrase my question.
In the end, I figured it out myself after discovering that pow(0.5, x); gives fractions of the power of 2.

As for my data:
On a calculator, round up the result of: ln(x)/ln(0.5)
And then do a (0.5^y) exponent: 0.5^rounded_UP_result

In code, it is:
pow(0.5, ceil(log(x)/log(0.5)));

Thanks anyway.
 

Related to Rounding decimals to ruler scale (log, pow math?)

1. What is the purpose of rounding decimals to ruler scale?

Rounding decimals to ruler scale is a mathematical technique used to simplify and approximate decimal numbers to a more manageable and easy-to-understand measurement. This is often used in fields such as engineering and construction, where precise measurements are necessary.

2. How do you round decimals to ruler scale?

To round decimals to ruler scale, first determine the desired unit of measurement (such as inches or centimeters) and the precision level (such as nearest quarter inch or nearest tenth of a centimeter). Then, follow the general rounding rules for decimals, adjusting the decimal point accordingly to get the desired measurement on the ruler scale.

3. Can decimals be rounded using logarithms or powers?

Yes, decimals can be rounded using logarithms or powers, but these methods may not be as commonly used for ruler scale rounding. Logarithms and powers are more often used for scientific calculations and data analysis, but can also be applied to rounding decimals in certain scenarios.

4. Is rounding to ruler scale the same as rounding to significant figures?

No, rounding to ruler scale and rounding to significant figures are two different methods of rounding. Rounding to ruler scale involves simplifying a decimal number to a specific unit of measurement, while rounding to significant figures focuses on expressing a number to a certain level of precision or accuracy.

5. What are some potential errors or limitations in rounding decimals to ruler scale?

One potential error in rounding decimals to ruler scale is the loss of precision, as rounding involves simplifying a number and discarding some of its digits. This can also lead to cumulative errors if rounding is done repeatedly. Additionally, rounding to ruler scale may not always result in the most accurate measurement, as it is an approximation and may not reflect the true value of the decimal number.

Similar threads

  • General Math
Replies
1
Views
759
  • General Discussion
Replies
18
Views
910
Replies
6
Views
3K
  • Computing and Technology
Replies
4
Views
853
  • General Math
Replies
2
Views
1K
Replies
2
Views
2K
Replies
2
Views
974
Replies
1
Views
3K
  • Special and General Relativity
Replies
11
Views
299
  • Engineering and Comp Sci Homework Help
Replies
3
Views
976
Back
Top