In Excel while Calculating =SIN(PI()) formula it returns 1.22515E-16.If the PI() Value(3.14159265358979) is directly given like =SIN(3.14159265358979), it returns 3.23114E-15.
Please anyone can share your opinion about how the excel calculates differently, when 'PI' and 3.14159265358979 are passed as parameter.
Let's have the following example:
A2 is formula =PI().
A3 is value 3.14159265358979.
A5 is value copied from A2 and then paste-special: Values only.
Formula in column B is =SIN(A2) ... =SIN(A5).
So what is happening here?
While Microsoft justifies the truncating values to 15 digits with using double floating point precision according IEEE 754, this is not the whole truth. According IEEE 754 the possible count of decimal digits is not exactly 15 but 15.95 in average. So there are more digits possible in some cases. And if so, Excel stores up to 17 digits in its files although it shows only 15 digits in its sheet views and also only 15 digits can be input in its sheet views.
So =PI() will result in 3.1415926535897931 exactly and this value will also be stored. But manual input can only be 3.14159265358979. But if you copy/paste-special:Values the result of =PI(), then also 3.1415926535897931 will be stored although only 3.14159265358979 is shown.
Since *.xlsx files are simply ZIP archives, we can unzip them and look at /xl/worksheets/sheet1.xml. There we will find:
<row r="2" spans="1:2" x14ac:dyDescent="0.25">
<c r="A2" s="1">
<f>PI()</f>
<v>3.1415926535897931</v>
</c>
<c r="B2">
<f>SIN(A2)</f>
<v>1.22514845490862E-16</v>
</c>
</row>
<row r="3" spans="1:2" x14ac:dyDescent="0.25">
<c r="A3" s="1">
<v>3.14159265358979</v>
</c>
<c r="B3">
<f>SIN(A3)</f>
<v>3.2311393144413003E-15</v>
</c>
</row>
<row r="5" spans="1:2" x14ac:dyDescent="0.25">
<c r="A5" s="1">
<v>3.1415926535897931</v>
</c>
<c r="B5">
<f>SIN(A5)</f>
<v>1.22514845490862E-16</v>
</c>
</row>
q.e.d.
The reason you are seeing this is because of a rounding error.
Sin(PI()) is technically 0, as detailed in the Sin function documentation. However, excel returns 1.22515E-16 or 0.0000000000000001225148455
(i.e. approximately 0)
3.14159265358979 is a approximation of PI(), so it returns a different number that it also approximately 0. If you try 3.1415926535897, 3.141592653589 etc, you will get a different number each time.
This is likely related to working with floats, but I don't know enough about Excel and how it stores data to elaborate.
The SIN() function accepts the parameter in radians.
To convert an angle to radians, the value must be multiplied by PI()/180.
If you use =SIN(PI()), the PI is considered as a radian which is equal to RADIANS(180). Both =SIN(PI()) and =SIN(RADIANS(180)) returns the same result 0.
=SIN(3.14159265358979) is not actually equal to =SIN(PI()) because the PI in this context is different. And hence the different result.
The bottom line is to always use radians as a parameter for trigonometric functions.
Related
I have been trying to apply some conditional formatting to numbers which are formatted externally as fractions with a mask ???/???. In trying to test whether the fraction has a numerator of 1, I apply the formula = =MOD(1/G62,0)<>0, which divides 1 by the fraction itself, which ought to divide with no remainder if it has a numerator of 1, and return 0. If it returns something else then it has a numerator other than 1.
The rule is satisfied when it should not be. To test what is going on, I deconstruct the formula.
The fraction 1/28 is divided into 1 to give 28 and this is correctly displayed. I then populate another cell using the formula =MOD(H62,1) to 28 and it gives 0, as it should. I do the same thing for 1/14 and the result is 1. In other words the MOD of 14, 1 is 1! When I look at the decimal representation of the 2 fractions( I imagine the fractions are actually the representations of the decimal numbers, which themselves will be binary or hex numbers internally), I see the following.
1/28 0.0357142857142856
1/14 0.0714285714285716
When the decimal for 1/28 is subtracted from the decimal for 1/14, the result is 0.035714285714286.
As 1/28 can probably never be accurately represented in decimal, it looks like some rounding down has taken place. Most probably when MOD is applied to the decimal representation of 1/28 with 1, that decimal representation of 1/14 does not divide equally into 1, and this discrepancy is disclosed by the subtraction above.
I am using excel 2016. Maybe this is no longer a problem.
What I am trying to do is test to see if the lowest numerator of a fractional number is 1. Perhaps there is another way to do this in Excel. If so, let me know.
I am expecting the result after rounding for 161.24 to be 161.5 and if the value is 161.75 then it must be rounded to 162, if it is 161.68 then it must be rounded to 162
I have used =MROUND(value, "0.5") but I dont get the expected result.
For what you expected, you should use:
=CEILING.MATH(value,0.5)
I am trying to write a rounding if statement. If cell <50 round to the nearest 5, if cell is >50 but <1000 round to the nearest 10, if cell is >1000 round to the nearest 100. Can anybody help me out?
My attempt
=IF((T2<50, ROUND(T2*2,-1)/2),IF(AND(T2>50,T2<1000,ROUND(T2,-1)),ROUND(T2,-2)))
I was able to write a similar statement (If cell >0 but <1000 round to nearest 10, otherwise round to nearest 50)
=IF(AND(S3>0,S3<1000),(ROUND((S3),-1)),(ROUND((S3)*2,-2)/2))
Try this:
=IF(A1<50,MROUND(A1,5), IF(AND(A1>=50,A1<1000),MROUND(A1,10),MROUND(A1, 100)))
The MROUND operator (documentation here) rounds to the nearest multiple, which I think is what you're looking for. You also have some issues with your paren grouping, but excel doesn't make it easy to chain if statements. Your AND statement needs to wrap just just the two evaluations and return MROUND(<cell>, 10) when true.
Did you just get a bit mixed up with the IF syntax?
=IF(T2<50, ROUND(T2*2,-1)/2,IF(AND(T2>50,T2<1000),ROUND(T2,-1),ROUND(T2,-2)))
The general form is
IF (logical test, result if true, result if false)
You also had some unnecessary brackets and didn't close the AND brackets.
I'm trying to understand what the first and last number value in points attribute represent, but MDN doesn't seem to explain this, it actually says there needs to be two numbers, however I keep seeing this first and last pattern. I keep noticing that there are pairs of numbers, the values that represent the x and y axis of the point, however their is just a single number that isn't a pair at the beginning and end?
<svg height="210" width="500">
<polygon points="100,10 40,198 190,78 10,78 160,198">//what does first and last number mean?
<style="fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;" />
</svg>
You are misinterpreting the numbers and their separators.
In a points value like the following:
100,10 40,198 190,78 10,78 160,198
The X and Y coordinates are separated by a comma, and the pairs are separated by a space (but using a comma is also allowed here).
So there are five X,Y coordinate pairs: (100,10) (40,198) (190,78) (10,78) and (160,198)
Can MS Excel do rounding but only up to the nearest thousandths place and ignore the rest of the decimals in a formula? I've tried value, fixed, round and none of these do what I need.
Let's say I have 100 square feet of space and I pay $1.00566399 per sq foot, I need the formula to round only up to the 5 and ignore the rest of the numbers because when you speak on longer terms it makes a difference in rate.
So I should be multiplying 100sf by $1.01 = $101.00 and not get 100sf * 1.00566399 = $101.57
=trunc(A1,5)
If you want to round up, maybe something like
=trunc((A1*10000+1)/10000,5)
Use the TRUNC($cellRef or number, Decimal places) function. It reduces the number of decimal places WITHOUT rounding, then do your math.
So for example:
=TRUNC(1.00566399,3)
=A1*ROUNDUP(B1,2)
Where A1 contains the number of square feet and B1 contains the price per square foot in it's original long decimal form.