Binary. Octal. Decimal. Hexadecimal conversion between
First, the conversion between decimal and binary (1) decimal to binary, is divided into an integer part and fractional part ① integral part of the way: In addition to taking over France 2, which will be integral parts of each divided by 2, for the remainder of Right the number, but to continue to divide by 2, the remainder a bit further to the right of the number, this step has been to continue until the business is 0 until the time the last reading, the remainder from the last time, has been to the top of the a remainder. The following are examples:Example: 168 decimal to binary conversion
The outcome will be converted to binary decimal 168, (10101000) 2
Analysis: The first step would be 168 divided by 2, Business 84, the remainder is 0.
The second step will be 84 divided by 2 operators, commercial number 42 I 0.
The third step will be 42 divided by 2 operators, the number of operators more than 21 to 0.
The fourth step would be 21 divided by 2 operators, the number of business more than 10 to 1.
The fifth step, the business 10 divided by 2, Business 5 the remainder is 0.
The sixth step, the business 5 divided by 2, remainder is 1 business 2.
Seventh step, the Business 2 divided by 2, Business 1, the remainder is 0.
Step eight would be 1 divided by 2 operators, business 0 remainder of 1.
Ninth step of reading, because the last one is only obtained after repeated divided by 2, so it is the highest place, reading the remainder of the word forward from the last time, that is, 10101000
(2) fractional method: Take 2 to take the whole law, be the fractional part multiplied by 2, then take the integer part, the remaining fractional part of the continuing multiplied by 2, then take the integer part, then multiplied by the fractional part of the remaining 2 fractional part of zero has been taken to date. If you can never be zero, the decimal rounding with the same number of decimal places as required retention time, under the back of a is 0 or 1, choice, if it is zero, give it up, if it is 1, to enter one. In other words, 0 round 1 entry. Reading back from the front of the integer read integer, the following example:
Example 1: The conversion to binary 0.125
Outcome: to convert a binary 0.125 (0.001) 2
Analysis: The first step would be 0.125 multiplied by 2, was 0.25, the integer part is 0, the fractional part 0.25;
The second step, the fractional part of 0.25 multiplied by 2, 0.5, 0 is an integer part, fractional part is 0.5;
The third step, the fractional part will be multiplied by 2, 0.5, 1.0, then the integer part of 1, the fractional part of 0.0;
The fourth step, reading, starting from the first reading, read the last one, that is, 0.001.
Example 2, the 0.45 is converted to binary (reserved to the fourth decimal point)
We can see from the above steps, when the fifth time to do multiplication, and the result is 0.4, then multiplied by the fractional part to 2, was 0.8,0.8 then multiplied by 2, to 1.6 this has been by it and eventually impossible be the fractional part of zero, so this time had to learn the method of rounding decimal, but binary only 0 and 1, 2, and so it was round 1 into 0. This is also the computer will produce errors in the conversion, but because the median number of reservations, high precision, it can be ignored.
So, we can conclude that the results will be converted to a binary equivalent to about 0.45 0.0111
Described above is converted to decimal to binary approach, need to note that:
1) decimal to binary, to be divided into two parts respectively, integer and fractional conversion
2) When converting an integer, with the addition of more than 2 out of law and the conversion decimal time, using a rounding method by 2
3) Note the direction of their reading, therefore, we approach from above, we can draw a decimal number converted to binary as 10,101,000.001 168.125, or 168.45 is converted to a binary decimal number about equal to 10101000.0111.
(3) is converted to decimal, regardless of the binary integer and fractional method: the right to add according to law, be multiplied by the binary number of each on the right, then the sum of which is a decimal number. Example will convert a binary number to decimal number 101.101.
Outcome: (101.101) 2 = (5.625) 10
We are doing the binary into decimal to note that
1) The right to know the value of each binary
2) to be able to calculate the value of each (Note: the weight behind the decimal point is 2 (1), 2 (2), etc.).
Decimal octal and hexadecimal transfer of principles with the principle of transfer as binary.
Related Posts of Binary. Octal. Decimal. Hexadecimal conversion between

BigDecimal to help double precise operation
double, float types can not be precisely expressed 0.1 double d1 = 5.85; double d2 = 3.21; Therefore, d1  d2 = 2.6399999999999997 At this point you can use the following method (based on number of decimal places amplified), but to prevent the value ...

spring scope = "prototype" and scope = "singleton" distinction between
<bean scope = "prototype"> <property name="meetsService" ref="meetsService" /> </ bean> "!  scope = "prototype" did not write any of the issues, projects or deletions from a table right ...

2010.02.03  Jquery ajax partial refresh dynamically updated
2010.02.03  Jquery ajax partial refresh dynamically updated the final results shown that the objectives to be achieved is: When I select a different time, the last time also followed a change, and will spread to a number of parameters of the background t

For a given number (float) rounded to two decimal places
For a given number (float) rounded to two decimal places

to retain two decimal places java
to retain two decimal places java questions: Mode 1: Rounding double f = 111231.5585; BigDecimal b = new BigDecimal (f); double f1 = b.setScale (2, BigDecimal.ROUND_HALF_UP). doubleValue (); Mode 2: java.text.DecimalFormat df = new java.text.DecimalF ...

Java operator
Java operators can be divided into four categories: arithmetic operators, relational operators, logical operators and bit operators. 1. Arithmetic Operators Java's arithmetic operators are divided into unary operators and binary operators. Unary opera

What is Jetty About Jetty Project
Jetty is an open source, standardsbased, fullfeatured server JAVA achieved. It Apache2.0 released under the agreement, so be free for commercial use and distribution. First in 1995, Jetty to benefit from a vast user community, there is a stable cor ...

in javascript how to get only two decimal places?
Cases sum = parseFloat (8.99) + parseFloat (7.50); Wait until the value is: 16.4900000002 How to get only two decimal places? <script language="JScript"> Number.prototype.toFixed = function (num) ( / / Restructure toFixed method, IE5 ...

AJAX without refreshing the chat room to achieve (download the attachment to the cabinet)
Before writing a small chat room of DEMO, a blog, in addition http://lvp.javaeye.com/blog/343236, download the attachment provided. However, this example brought about automatically refresh the page to experience a sense of bad, and when the contents reac

Ruby in the meaning of keywords
1, break out of the cycle when the layer 2, next neglect the remainder of the cycle to begin the next cycle 3, redo a fresh start cycle, or the beginning of this first 4, retry to start the loop 5, $ array <<value to value as an array element add an