Can windows calculator convert decimal fractions to binary?











up vote
-3
down vote

favorite












Suppose I have a fractional decimal number like 0.21



Can the windows calculator convert that to binary?



If I try to type in 0.21 while in programmer mode, it doesn't respond to the decimal point. It's like I can't type in a decimal point in programmer mode.. And I can't type a binary point in programmer mode either when I select binary within programmer mode. The 'point' seems to be disabled.



I am using windows 7. I don't know if this has been enabled in windows 10?



Added

Or how about a simpler example like 2.5 or 5.125 So, a fractional part that can be represented in binary? So for 2.5 that calc should show 010.10 or 1.10*2^3. Or for 5.125 the calc should show 0101.001 or 1.01001*2^5 Can the windows calculator show that?










share|improve this question
























  • This is because you cannot represent fractions in binary.
    – Keltari
    Nov 27 '17 at 21:49










  • Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
    – nurchi
    Nov 27 '17 at 22:55












  • @nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
    – barlop
    Nov 28 '17 at 3:49












  • Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
    – nurchi
    Dec 15 '17 at 20:29















up vote
-3
down vote

favorite












Suppose I have a fractional decimal number like 0.21



Can the windows calculator convert that to binary?



If I try to type in 0.21 while in programmer mode, it doesn't respond to the decimal point. It's like I can't type in a decimal point in programmer mode.. And I can't type a binary point in programmer mode either when I select binary within programmer mode. The 'point' seems to be disabled.



I am using windows 7. I don't know if this has been enabled in windows 10?



Added

Or how about a simpler example like 2.5 or 5.125 So, a fractional part that can be represented in binary? So for 2.5 that calc should show 010.10 or 1.10*2^3. Or for 5.125 the calc should show 0101.001 or 1.01001*2^5 Can the windows calculator show that?










share|improve this question
























  • This is because you cannot represent fractions in binary.
    – Keltari
    Nov 27 '17 at 21:49










  • Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
    – nurchi
    Nov 27 '17 at 22:55












  • @nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
    – barlop
    Nov 28 '17 at 3:49












  • Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
    – nurchi
    Dec 15 '17 at 20:29













up vote
-3
down vote

favorite









up vote
-3
down vote

favorite











Suppose I have a fractional decimal number like 0.21



Can the windows calculator convert that to binary?



If I try to type in 0.21 while in programmer mode, it doesn't respond to the decimal point. It's like I can't type in a decimal point in programmer mode.. And I can't type a binary point in programmer mode either when I select binary within programmer mode. The 'point' seems to be disabled.



I am using windows 7. I don't know if this has been enabled in windows 10?



Added

Or how about a simpler example like 2.5 or 5.125 So, a fractional part that can be represented in binary? So for 2.5 that calc should show 010.10 or 1.10*2^3. Or for 5.125 the calc should show 0101.001 or 1.01001*2^5 Can the windows calculator show that?










share|improve this question















Suppose I have a fractional decimal number like 0.21



Can the windows calculator convert that to binary?



If I try to type in 0.21 while in programmer mode, it doesn't respond to the decimal point. It's like I can't type in a decimal point in programmer mode.. And I can't type a binary point in programmer mode either when I select binary within programmer mode. The 'point' seems to be disabled.



I am using windows 7. I don't know if this has been enabled in windows 10?



Added

Or how about a simpler example like 2.5 or 5.125 So, a fractional part that can be represented in binary? So for 2.5 that calc should show 010.10 or 1.10*2^3. Or for 5.125 the calc should show 0101.001 or 1.01001*2^5 Can the windows calculator show that?







windows-7 calculator






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 18 '17 at 18:02

























asked Nov 27 '17 at 21:39









barlop

15.3k2287145




15.3k2287145












  • This is because you cannot represent fractions in binary.
    – Keltari
    Nov 27 '17 at 21:49










  • Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
    – nurchi
    Nov 27 '17 at 22:55












  • @nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
    – barlop
    Nov 28 '17 at 3:49












  • Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
    – nurchi
    Dec 15 '17 at 20:29


















  • This is because you cannot represent fractions in binary.
    – Keltari
    Nov 27 '17 at 21:49










  • Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
    – nurchi
    Nov 27 '17 at 22:55












  • @nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
    – barlop
    Nov 28 '17 at 3:49












  • Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
    – nurchi
    Dec 15 '17 at 20:29
















This is because you cannot represent fractions in binary.
– Keltari
Nov 27 '17 at 21:49




This is because you cannot represent fractions in binary.
– Keltari
Nov 27 '17 at 21:49












Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
– nurchi
Nov 27 '17 at 22:55






Not entirely correct. You can, but Windows calculator doesn't show. When we see a number, say 123, we don't even think this way, but in reality, the number can be broken down into 1*10^2 + 2*10^1 + 10^0, by the same logic, 123.45 is 1*10^2 + 2*10^1 + 3*10^0 + 4*10^(-1) + 5*10^(-2). The exact same thing happens with the binary math, except you only have 2 digits (represented by 0 and 1) and the base of the system is 2, not 10. So 0.21 could be viewed as 0.0011010111 which is approximated as 0.209961, I only did 10 binary digits, IEEE-754 standard specifies a lot more...
– nurchi
Nov 27 '17 at 22:55














@nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
– barlop
Nov 28 '17 at 3:49






@nurchi You mean that Keltari is not correct. You're replying to Keltari not to me, so please write AT Keltari at the start of your comment, so it's clear you were referring to him and not to me
– barlop
Nov 28 '17 at 3:49














Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
– nurchi
Dec 15 '17 at 20:29




Seems like I cannot edit my comment anymore, but yes, I was referring to @Keltari's comment, not the question itself.
– nurchi
Dec 15 '17 at 20:29










2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted










@Keltari Generally, fraction value CAN be represented in binary, using kind of "binary point" (counterpart of decimal point). In fact, that is how real/double numbers are represented in computers (although usually binary point position is stored, instead of the "point character"). But remember: not all decimal fractions can be represented in binary form exactly - some rounding must be applied then, especially if only limited count of bits can be used (which is always true in real computer science world).



Unfortunatelly, windows calculator in programmer's mode operate on integer values only. A workaround to achieve your goal is like this:




  1. In standard mode enter a decimal number (can be fractional) to convert, e.g. 0.21


  2. Multiply it by 2 (keys: * 2 =)



  3. Repeat step 2 (pressing = key alone, again and again), until you receive number which is integer - or very close to integer (see remark below).



    IMPORTANT! Remember, how many times you multiplied initial value by 2 (in step 2 and repeated 3).



  4. Switch to programmer's mode and enter value received after step 3, rounded to integer (unfortunately, that is not done automatically when switching mode, at least in Windows 10's Calculator app).


  5. The binary representation of the integer number is shown. Imagine, the binary point is on the most right (after last binary digit). Then, move it left by as many positions as you have done multiplying in step 2 and 3. Add leading 0's as needed.



Example:




  • Original value: 0.21

  • Multiply it by 2 ten times - you get 215,04. Assuming that it is close enough to an integer value (it is arbitrary decision!), you get the rounded integer of 215

  • Entering 215 in programmer's mode shows its binary representation: 11010111

  • Moving the binary point 10 places left, gives: .0011010111


Remark: As I mentioned earlier, not all decimal fraction values can be represented exactly in binary form, so sometimes you must decide, what precision (approximation) satisfy your needs. In the example above, I assumed that rounding 215,04 to 215 is comparatively small "error" (below 1/5000), so 10 bits was enough to represent the original number. If I needed greater precision, I would make multiplying by 2 not ten, but maybe twenty times (result: 220200,96 rounded to 220201 as an integer) and would get 20-bits binary representation .00110101110000101001 (with "error" below 1/5000000).



BTW Usually count of bits used to represent data in computers is power of 2 - 8, 16, 32, 64, sometimes 48, etc. In such a case, you can simply use faster "multipling by 2" method in the calculator, suggested by you in comment below (*(2^n)).






share|improve this answer























  • Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
    – barlop
    Nov 28 '17 at 4:12










  • C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
    – barlop
    Nov 28 '17 at 4:12










  • @barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
    – AnSi
    Nov 28 '17 at 9:51












  • Nice workaround, @AnSi
    – nurchi
    Dec 15 '17 at 20:34










  • There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
    – barlop
    Dec 18 '17 at 12:31




















up vote
1
down vote













So the way fractions are represented in memory is according to the IEEE-754 standard for floating point numbers.



A number as simple as decimal 123 when stored as floating point number (e.g. 123.0) is actually stored as 1.921875 * 2^6 = 1.921875 * 64



Think of this as a scientific notation, which is a * 10^b, where a must be [1, 10) (meaning from 1.0 up to, but not including 10, e.g. 9.999...8)



Your number 0.21 is stored in memory as 1.6799999475479126 * 2^(-3) which is equivalent to 0.20999999344348907470703125 (windows calculator shows this as 0.209999993443489075 when calculating manually)



Any calculator that utilises this standard will store numbers in the same format (if it doesn't, excluding different endianness, it probably has a different way of storing floating point numbers, so when passing values from one piece of software/hardware to another, translation must happen, but this is a different topic altogether).



Now, to answer your question, while Windows calculator stores the numbers in this form, it hasn't been designed to show you the intermediate/raw values in the memory. If you really felt like it, you could use a memory viewing tool and spy on values as you type them in the calculator, but again, that is a different topic...



Check out https://www.h-schmidt.net/FloatConverter/IEEE754.html to have an idea of how the floating point numbers are stored and represented.






share|improve this answer





















  • I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
    – barlop
    Nov 28 '17 at 3:53











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1272250%2fcan-windows-calculator-convert-decimal-fractions-to-binary%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










@Keltari Generally, fraction value CAN be represented in binary, using kind of "binary point" (counterpart of decimal point). In fact, that is how real/double numbers are represented in computers (although usually binary point position is stored, instead of the "point character"). But remember: not all decimal fractions can be represented in binary form exactly - some rounding must be applied then, especially if only limited count of bits can be used (which is always true in real computer science world).



Unfortunatelly, windows calculator in programmer's mode operate on integer values only. A workaround to achieve your goal is like this:




  1. In standard mode enter a decimal number (can be fractional) to convert, e.g. 0.21


  2. Multiply it by 2 (keys: * 2 =)



  3. Repeat step 2 (pressing = key alone, again and again), until you receive number which is integer - or very close to integer (see remark below).



    IMPORTANT! Remember, how many times you multiplied initial value by 2 (in step 2 and repeated 3).



  4. Switch to programmer's mode and enter value received after step 3, rounded to integer (unfortunately, that is not done automatically when switching mode, at least in Windows 10's Calculator app).


  5. The binary representation of the integer number is shown. Imagine, the binary point is on the most right (after last binary digit). Then, move it left by as many positions as you have done multiplying in step 2 and 3. Add leading 0's as needed.



Example:




  • Original value: 0.21

  • Multiply it by 2 ten times - you get 215,04. Assuming that it is close enough to an integer value (it is arbitrary decision!), you get the rounded integer of 215

  • Entering 215 in programmer's mode shows its binary representation: 11010111

  • Moving the binary point 10 places left, gives: .0011010111


Remark: As I mentioned earlier, not all decimal fraction values can be represented exactly in binary form, so sometimes you must decide, what precision (approximation) satisfy your needs. In the example above, I assumed that rounding 215,04 to 215 is comparatively small "error" (below 1/5000), so 10 bits was enough to represent the original number. If I needed greater precision, I would make multiplying by 2 not ten, but maybe twenty times (result: 220200,96 rounded to 220201 as an integer) and would get 20-bits binary representation .00110101110000101001 (with "error" below 1/5000000).



BTW Usually count of bits used to represent data in computers is power of 2 - 8, 16, 32, 64, sometimes 48, etc. In such a case, you can simply use faster "multipling by 2" method in the calculator, suggested by you in comment below (*(2^n)).






share|improve this answer























  • Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
    – barlop
    Nov 28 '17 at 4:12










  • C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
    – barlop
    Nov 28 '17 at 4:12










  • @barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
    – AnSi
    Nov 28 '17 at 9:51












  • Nice workaround, @AnSi
    – nurchi
    Dec 15 '17 at 20:34










  • There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
    – barlop
    Dec 18 '17 at 12:31

















up vote
2
down vote



accepted










@Keltari Generally, fraction value CAN be represented in binary, using kind of "binary point" (counterpart of decimal point). In fact, that is how real/double numbers are represented in computers (although usually binary point position is stored, instead of the "point character"). But remember: not all decimal fractions can be represented in binary form exactly - some rounding must be applied then, especially if only limited count of bits can be used (which is always true in real computer science world).



Unfortunatelly, windows calculator in programmer's mode operate on integer values only. A workaround to achieve your goal is like this:




  1. In standard mode enter a decimal number (can be fractional) to convert, e.g. 0.21


  2. Multiply it by 2 (keys: * 2 =)



  3. Repeat step 2 (pressing = key alone, again and again), until you receive number which is integer - or very close to integer (see remark below).



    IMPORTANT! Remember, how many times you multiplied initial value by 2 (in step 2 and repeated 3).



  4. Switch to programmer's mode and enter value received after step 3, rounded to integer (unfortunately, that is not done automatically when switching mode, at least in Windows 10's Calculator app).


  5. The binary representation of the integer number is shown. Imagine, the binary point is on the most right (after last binary digit). Then, move it left by as many positions as you have done multiplying in step 2 and 3. Add leading 0's as needed.



Example:




  • Original value: 0.21

  • Multiply it by 2 ten times - you get 215,04. Assuming that it is close enough to an integer value (it is arbitrary decision!), you get the rounded integer of 215

  • Entering 215 in programmer's mode shows its binary representation: 11010111

  • Moving the binary point 10 places left, gives: .0011010111


Remark: As I mentioned earlier, not all decimal fraction values can be represented exactly in binary form, so sometimes you must decide, what precision (approximation) satisfy your needs. In the example above, I assumed that rounding 215,04 to 215 is comparatively small "error" (below 1/5000), so 10 bits was enough to represent the original number. If I needed greater precision, I would make multiplying by 2 not ten, but maybe twenty times (result: 220200,96 rounded to 220201 as an integer) and would get 20-bits binary representation .00110101110000101001 (with "error" below 1/5000000).



BTW Usually count of bits used to represent data in computers is power of 2 - 8, 16, 32, 64, sometimes 48, etc. In such a case, you can simply use faster "multipling by 2" method in the calculator, suggested by you in comment below (*(2^n)).






share|improve this answer























  • Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
    – barlop
    Nov 28 '17 at 4:12










  • C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
    – barlop
    Nov 28 '17 at 4:12










  • @barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
    – AnSi
    Nov 28 '17 at 9:51












  • Nice workaround, @AnSi
    – nurchi
    Dec 15 '17 at 20:34










  • There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
    – barlop
    Dec 18 '17 at 12:31















up vote
2
down vote



accepted







up vote
2
down vote



accepted






@Keltari Generally, fraction value CAN be represented in binary, using kind of "binary point" (counterpart of decimal point). In fact, that is how real/double numbers are represented in computers (although usually binary point position is stored, instead of the "point character"). But remember: not all decimal fractions can be represented in binary form exactly - some rounding must be applied then, especially if only limited count of bits can be used (which is always true in real computer science world).



Unfortunatelly, windows calculator in programmer's mode operate on integer values only. A workaround to achieve your goal is like this:




  1. In standard mode enter a decimal number (can be fractional) to convert, e.g. 0.21


  2. Multiply it by 2 (keys: * 2 =)



  3. Repeat step 2 (pressing = key alone, again and again), until you receive number which is integer - or very close to integer (see remark below).



    IMPORTANT! Remember, how many times you multiplied initial value by 2 (in step 2 and repeated 3).



  4. Switch to programmer's mode and enter value received after step 3, rounded to integer (unfortunately, that is not done automatically when switching mode, at least in Windows 10's Calculator app).


  5. The binary representation of the integer number is shown. Imagine, the binary point is on the most right (after last binary digit). Then, move it left by as many positions as you have done multiplying in step 2 and 3. Add leading 0's as needed.



Example:




  • Original value: 0.21

  • Multiply it by 2 ten times - you get 215,04. Assuming that it is close enough to an integer value (it is arbitrary decision!), you get the rounded integer of 215

  • Entering 215 in programmer's mode shows its binary representation: 11010111

  • Moving the binary point 10 places left, gives: .0011010111


Remark: As I mentioned earlier, not all decimal fraction values can be represented exactly in binary form, so sometimes you must decide, what precision (approximation) satisfy your needs. In the example above, I assumed that rounding 215,04 to 215 is comparatively small "error" (below 1/5000), so 10 bits was enough to represent the original number. If I needed greater precision, I would make multiplying by 2 not ten, but maybe twenty times (result: 220200,96 rounded to 220201 as an integer) and would get 20-bits binary representation .00110101110000101001 (with "error" below 1/5000000).



BTW Usually count of bits used to represent data in computers is power of 2 - 8, 16, 32, 64, sometimes 48, etc. In such a case, you can simply use faster "multipling by 2" method in the calculator, suggested by you in comment below (*(2^n)).






share|improve this answer














@Keltari Generally, fraction value CAN be represented in binary, using kind of "binary point" (counterpart of decimal point). In fact, that is how real/double numbers are represented in computers (although usually binary point position is stored, instead of the "point character"). But remember: not all decimal fractions can be represented in binary form exactly - some rounding must be applied then, especially if only limited count of bits can be used (which is always true in real computer science world).



Unfortunatelly, windows calculator in programmer's mode operate on integer values only. A workaround to achieve your goal is like this:




  1. In standard mode enter a decimal number (can be fractional) to convert, e.g. 0.21


  2. Multiply it by 2 (keys: * 2 =)



  3. Repeat step 2 (pressing = key alone, again and again), until you receive number which is integer - or very close to integer (see remark below).



    IMPORTANT! Remember, how many times you multiplied initial value by 2 (in step 2 and repeated 3).



  4. Switch to programmer's mode and enter value received after step 3, rounded to integer (unfortunately, that is not done automatically when switching mode, at least in Windows 10's Calculator app).


  5. The binary representation of the integer number is shown. Imagine, the binary point is on the most right (after last binary digit). Then, move it left by as many positions as you have done multiplying in step 2 and 3. Add leading 0's as needed.



Example:




  • Original value: 0.21

  • Multiply it by 2 ten times - you get 215,04. Assuming that it is close enough to an integer value (it is arbitrary decision!), you get the rounded integer of 215

  • Entering 215 in programmer's mode shows its binary representation: 11010111

  • Moving the binary point 10 places left, gives: .0011010111


Remark: As I mentioned earlier, not all decimal fraction values can be represented exactly in binary form, so sometimes you must decide, what precision (approximation) satisfy your needs. In the example above, I assumed that rounding 215,04 to 215 is comparatively small "error" (below 1/5000), so 10 bits was enough to represent the original number. If I needed greater precision, I would make multiplying by 2 not ten, but maybe twenty times (result: 220200,96 rounded to 220201 as an integer) and would get 20-bits binary representation .00110101110000101001 (with "error" below 1/5000000).



BTW Usually count of bits used to represent data in computers is power of 2 - 8, 16, 32, 64, sometimes 48, etc. In such a case, you can simply use faster "multipling by 2" method in the calculator, suggested by you in comment below (*(2^n)).







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 6 at 15:12

























answered Nov 27 '17 at 23:23









AnSi

363




363












  • Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
    – barlop
    Nov 28 '17 at 4:12










  • C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
    – barlop
    Nov 28 '17 at 4:12










  • @barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
    – AnSi
    Nov 28 '17 at 9:51












  • Nice workaround, @AnSi
    – nurchi
    Dec 15 '17 at 20:34










  • There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
    – barlop
    Dec 18 '17 at 12:31




















  • Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
    – barlop
    Nov 28 '17 at 4:12










  • C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
    – barlop
    Nov 28 '17 at 4:12










  • @barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
    – AnSi
    Nov 28 '17 at 9:51












  • Nice workaround, @AnSi
    – nurchi
    Dec 15 '17 at 20:34










  • There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
    – barlop
    Dec 18 '17 at 12:31


















Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
– barlop
Nov 28 '17 at 4:12




Very interesting.. a few observations.. A)step 2 can be sped up with the x^y button on the window calculator. in scientific mode. e.g. 0.21*2^30 The integer part of that number can then be converted to binary in the windows calculator. B)Where you wrote "multiply it 10 times by 2" I think you meant multiply it by 2 ten times, / 10 times, multiply it by 2, i.e. 2^10.
– barlop
Nov 28 '17 at 4:12












C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
– barlop
Nov 28 '17 at 4:12




C)Interestingly I learnt a much slower method than your method, the method I learnt was each time you multiply it by two, if the number is <1 then write a 0 in your result string. If the number is >= 1, you subtract one and write a 1 in your result string. .
– barlop
Nov 28 '17 at 4:12












@barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
– AnSi
Nov 28 '17 at 9:51






@barlop ad. A) Yes, using x^y operation is much faster, and is usefull if you know in advance, how many bits you are going to use for binary representation (y in the formula). ad. B) Sorry for any misleading expressions - English is not my mothers' language :-) - edited as you suggested
– AnSi
Nov 28 '17 at 9:51














Nice workaround, @AnSi
– nurchi
Dec 15 '17 at 20:34




Nice workaround, @AnSi
– nurchi
Dec 15 '17 at 20:34












There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
– barlop
Dec 18 '17 at 12:31






There is no need to write in your first sentence that fractions "CAN" be represented in binary. I know they can. The only person that said they can't is one commenter "nurchi". But an answer is assumed to be addressed to the person that asked the question - me. So there is no need to so emphatically state something in your first sentence that I already agree with. That entire first sentence is superfluous. I even mentioned "binary point" in my question so i'm well aware of it
– barlop
Dec 18 '17 at 12:31














up vote
1
down vote













So the way fractions are represented in memory is according to the IEEE-754 standard for floating point numbers.



A number as simple as decimal 123 when stored as floating point number (e.g. 123.0) is actually stored as 1.921875 * 2^6 = 1.921875 * 64



Think of this as a scientific notation, which is a * 10^b, where a must be [1, 10) (meaning from 1.0 up to, but not including 10, e.g. 9.999...8)



Your number 0.21 is stored in memory as 1.6799999475479126 * 2^(-3) which is equivalent to 0.20999999344348907470703125 (windows calculator shows this as 0.209999993443489075 when calculating manually)



Any calculator that utilises this standard will store numbers in the same format (if it doesn't, excluding different endianness, it probably has a different way of storing floating point numbers, so when passing values from one piece of software/hardware to another, translation must happen, but this is a different topic altogether).



Now, to answer your question, while Windows calculator stores the numbers in this form, it hasn't been designed to show you the intermediate/raw values in the memory. If you really felt like it, you could use a memory viewing tool and spy on values as you type them in the calculator, but again, that is a different topic...



Check out https://www.h-schmidt.net/FloatConverter/IEEE754.html to have an idea of how the floating point numbers are stored and represented.






share|improve this answer





















  • I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
    – barlop
    Nov 28 '17 at 3:53















up vote
1
down vote













So the way fractions are represented in memory is according to the IEEE-754 standard for floating point numbers.



A number as simple as decimal 123 when stored as floating point number (e.g. 123.0) is actually stored as 1.921875 * 2^6 = 1.921875 * 64



Think of this as a scientific notation, which is a * 10^b, where a must be [1, 10) (meaning from 1.0 up to, but not including 10, e.g. 9.999...8)



Your number 0.21 is stored in memory as 1.6799999475479126 * 2^(-3) which is equivalent to 0.20999999344348907470703125 (windows calculator shows this as 0.209999993443489075 when calculating manually)



Any calculator that utilises this standard will store numbers in the same format (if it doesn't, excluding different endianness, it probably has a different way of storing floating point numbers, so when passing values from one piece of software/hardware to another, translation must happen, but this is a different topic altogether).



Now, to answer your question, while Windows calculator stores the numbers in this form, it hasn't been designed to show you the intermediate/raw values in the memory. If you really felt like it, you could use a memory viewing tool and spy on values as you type them in the calculator, but again, that is a different topic...



Check out https://www.h-schmidt.net/FloatConverter/IEEE754.html to have an idea of how the floating point numbers are stored and represented.






share|improve this answer





















  • I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
    – barlop
    Nov 28 '17 at 3:53













up vote
1
down vote










up vote
1
down vote









So the way fractions are represented in memory is according to the IEEE-754 standard for floating point numbers.



A number as simple as decimal 123 when stored as floating point number (e.g. 123.0) is actually stored as 1.921875 * 2^6 = 1.921875 * 64



Think of this as a scientific notation, which is a * 10^b, where a must be [1, 10) (meaning from 1.0 up to, but not including 10, e.g. 9.999...8)



Your number 0.21 is stored in memory as 1.6799999475479126 * 2^(-3) which is equivalent to 0.20999999344348907470703125 (windows calculator shows this as 0.209999993443489075 when calculating manually)



Any calculator that utilises this standard will store numbers in the same format (if it doesn't, excluding different endianness, it probably has a different way of storing floating point numbers, so when passing values from one piece of software/hardware to another, translation must happen, but this is a different topic altogether).



Now, to answer your question, while Windows calculator stores the numbers in this form, it hasn't been designed to show you the intermediate/raw values in the memory. If you really felt like it, you could use a memory viewing tool and spy on values as you type them in the calculator, but again, that is a different topic...



Check out https://www.h-schmidt.net/FloatConverter/IEEE754.html to have an idea of how the floating point numbers are stored and represented.






share|improve this answer












So the way fractions are represented in memory is according to the IEEE-754 standard for floating point numbers.



A number as simple as decimal 123 when stored as floating point number (e.g. 123.0) is actually stored as 1.921875 * 2^6 = 1.921875 * 64



Think of this as a scientific notation, which is a * 10^b, where a must be [1, 10) (meaning from 1.0 up to, but not including 10, e.g. 9.999...8)



Your number 0.21 is stored in memory as 1.6799999475479126 * 2^(-3) which is equivalent to 0.20999999344348907470703125 (windows calculator shows this as 0.209999993443489075 when calculating manually)



Any calculator that utilises this standard will store numbers in the same format (if it doesn't, excluding different endianness, it probably has a different way of storing floating point numbers, so when passing values from one piece of software/hardware to another, translation must happen, but this is a different topic altogether).



Now, to answer your question, while Windows calculator stores the numbers in this form, it hasn't been designed to show you the intermediate/raw values in the memory. If you really felt like it, you could use a memory viewing tool and spy on values as you type them in the calculator, but again, that is a different topic...



Check out https://www.h-schmidt.net/FloatConverter/IEEE754.html to have an idea of how the floating point numbers are stored and represented.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 27 '17 at 22:45









nurchi

18916




18916












  • I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
    – barlop
    Nov 28 '17 at 3:53


















  • I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
    – barlop
    Nov 28 '17 at 3:53
















I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
– barlop
Nov 28 '17 at 3:53




I notice this website gives a binary string for it, decimal-to-binary.com/… But it also an approxiation 'cos its string of 0.00110101110 is 1/8 + 1/16 + 1/64 + 1/256 + 1/512 + 1/1024 = (128/1024+64/1024+16/1024+4/1024+2/1024+1/1024)= 215/2014 = 0.2099609375 which is even less accurate than the approximation you gave.
– barlop
Nov 28 '17 at 3:53


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1272250%2fcan-windows-calculator-convert-decimal-fractions-to-binary%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

Eduardo VII do Reino Unido