Format integers as fraction - excel

I have a list of fractions in Excel which I want to format as fractions, including integers. However, by default Excel formats integers as integers which is understandable.
Is there any way to force Excel to format, say, 4/4 as 4/4 instead of 1?
I need it to be stores as values and not as text, so '4/4 wont work. As I need to average a bunch of values from it afterwards.
Apparently I'm the first person ever to take issue with this, because google provides absolutely no help whatsoever :o

Yes, use a custom number format:
?/4

I don't believe what you are trying to accomplish is doable outright, as fractions are really division problems. However, with some formula trickery, you may be able to get something that will work for you.
If you place '7/8 in cell A1 and then use the following formula in cell B1
=DECIMAL(MID(A1,1,FIND("/",A1,1)-1),10)/DECIMAL(MID(A1,FIND("/",A1,1)+1,LEN(A1)),10)
The cell will display the decimal value of the "fraction", in this case 0.875 allowing you to change the denominator at will and still perform math functions.
This works because the formula slices up the "fraction" stored as text and converts it to a number and performs the math.

Related

Excel sumif returns big number instead of zero

I have a column of positive and negative numbers, which when summed should balance to zero (it's an accounting sheet).
However, if I use a SUMIF formula, instead of 0, i get:
1.81899E-12 or -9.09495E-13 or similar. (I don't know what this sort of result is called, but I think they represent very large or very small numbers)
I have created a sample document which shows the issue.
It returns a zero if the cell is formatted as a number, but the above result if formatted as general.
I often also find that even the simple SUM function also returns a similar result, as does the SUM in the status bar at the bottom of excel, so it is not just the SUMIF function I am struggling with. However, I have been unable to recreate the issue with the SUM function in my example spreadsheet.
I'm using Excel as part of Home and Business 2013.
Thanks for your help.
As #Dominique pointed out, xxxE-12 is a very, very small number. It is very, very close to zero.
xxxE-12 is Excel's (and most programming languages') way of writing xxx * 10^-12.
As you guessed, this is due to rounding. It however also displays the issues of how computers handles floating-point (decimal) numbers; what you think is 1 / 3 = 0.333 might be represented internally as something like 0.333333681. See https://en.wikipedia.org/wiki/Floating-point_arithmetic, or notably https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems.
Secondly, why this appears if the cell is formatted as "General", but not "Number"? With "Number", you expect an integer part and at most, say, 3 decimals. x.xxE-12 has the largest non-zero component at the 12th (!) decimal. So when displayed, it gets rounded to a nice zero. "General" however attempts to display the number as close to the actual value, which in this case is the xxxE-12.
Also note that this might give you issues if you try to compare your calculated value with zero. Say, =IF(SUMIF(...) = 0, ...; it might not evaluate to TRUE even when you think it does (due to the very small value). The solution is instead to compare the difference of calculated value to zero: =IF(ABS(SUMIF(...) - 0) < 1E-9, ....

How to convert decimal to binary in excel without using the engineering functions

I am trying to learn the fundamentals behind the conversion of binary to decimal/Hex/Oct. For now I am focusing on decimal to binary conversion, without the use of the engineering functions dec2bin. I haven't found much online regarding this.
Thus far I have figured out how to convert a cell with a positive decimal number inside of it into 8 boxes (8 bits) making up 0's and 1's.
The way I have done this is using the MOD and INT functions.
First bit with formula
2nd Bit with formula
In the above two images I show how I manually calculate the process of converting from decimal to binary. The question is, this is the long way of doing it and I would like help to make it so that it is simply two boxes; one with a decimal and the other with the binary, so that when I enter the decimal it is instantly calculated into the binary beside it, as demonstrated in picture 3.
decimal to binary short form
If anyone could help me understand how to make my formula work using just one cell instead of 8 separate and different formulaes, it would be appreciated.
Use CONCAT as an Array formula:
=CONCAT(INT(MOD(A3/2^(8-ROW($1:$8)),2)))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
CONCAT was introduced with Office 365 Excel.
If one does not have Concat, this can be done with TEXT and SUMPRODUCT:
=TEXT(SUMPRODUCT(INT(MOD(A3/2^(8-ROW($1:$8)),2))*(10^(8-ROW($1:$8)))),"00000000")

Why am I obtaining this strange value multiplying 2 number having different format using Excel?

I am very new to Excel and I have a problem with a simple multiplication (I know, it is depressing but I'm stuck).
I have to multiply the numeric content of 2 cells (these value are calculated using 2 different formulas).
The problem is that it seems that these 2 cells contain numeric values having different format and I obtain a strange result.
Infact I have:
1) The K3 cell containing this value: 0,0783272400
2) The K6 cell containing this value: 728.454911165
In another cell I simply do:
=K3*K6
but now I am obtaining this nonsense value: 57.057.862.655,9996000000
I think that the problem could be related to the fact that the first one use the , do divide integer section and decimal section, and in the other one I am using . to divider the integer section and decimal section.
How can I correctly handle this situation?
Format both values as Currency in Excel and forget about the issue.
You are getting it, because the floating point values are not represented differently in many programming languages. In Excel probably the best way to make sure you do not give strange values is to format as Currency.
Or in VBA to use the CDec and to convert to decimal.
Is floating point math broken?
Excel is treating 0,0783272400 as something less than one tenth and 728.454911165 as getting on for one thousand billion. The result is formatted with . for thousands separator and , for decimal separator - and is not nonsensical (though the choice of formatting is).

Excel roundings not summing properly

I have a excel sheet with a few formulas like this:
A1,A2,A3= 0.13,1.25,2.21
A4: =(A1*A2) =0.16 ( 2 decimal points)
A5: =(A2*A3) =2.76 ( 2 decimal points)
A6: =SUM(A4;A5) =2.93 ( 2 decimal points )
And i want to show 0.16+2.76=2.92
well, there's my problem in bold. i want to add the values from the cells, not the formuls result. How can i do that ? Thank you
Presumably you're working with money which is why you need this.
One way to resolve this is to use =ROUND(A1*A2, 2) etc. and base your subsequent calculations from that.
Do be aware though that you will still occasionally get spurious results due to Excel using a 64 bit IEEE754 floating point double to represent numbers. (Although it does have some extremely clever circumvention techniques - see how it evaluates 1/3 + 1/3 + 1/3 - it will not resolve every possible oddity). If you're building an accounting-style sheet you are best off working in pence, and dividing the final result.
Round the values before you sum, ie:
=ROUND(A1*A2,2)
=ROUND(A2*A3,2)
You could wrap your formulas with the ROUND function:
=ROUND(A1*A2,2)
This will give you 0.16 as opposed to 0.163. Do this for each of your calculations and you'll only be calculating everything to two decimal places. Although I'm not sure why you'd want to do that.

Certain fractions being calculated in excel 2013

I'm creating a simple spreadsheet to calculate some betting odds and keeping track of my wins/losses
when I put fractional odds in one column Excel converts some of them to whole numbers (i.e. the ones that are 1/1, 2/1, etc where it does not do it for odds like 4/11, 7/2, etc.
Is there a way of turning this off?
Please note that some of the top heave fractions (11/2, 11/10 etc) get put into whole numbers such as 5 1/2 etc! And I do not want this to occur either
I've tried the Custom formatting of the cells but all of the denominators will inevitably be different, so having something like ??/28 won't work for me
EDIT:
This was solved using the custom format ??/?? and simply removeing the # that was at the front of the custom cell format dialog box
You simply need to change the cell format; you want to use ???/???. This will make Excel represent any decimal number to the closest fraction approximation it can find using the specified numerator and denominator significant digits (number of ? in the format string)
If the cell input is directly a fraction, it will reduce it if possible but always keeping the fraction format.
Examples:
= .10 will be converted to 1/10
= 0.1231 will be converted to 81/658 (supossing ???/??? format is used).
= 10/100 will be converted to 1/10
= 11/12 will remain as 11/12 as no reduction is possible.
= 1/1 will remain as 1/1
etc.
The behavior you are describing is becuase you are using one of Excel's default fraction formats which are all similar to # ???/??? (take note of the leading #). This format will reduce integral values to the non fractional part.
You could use text format for the cells with the odds, and then the VALUE function in any calculations you need to do with them

Resources