DS18B20 with only OneWire library
Actually he isn't really converting float to int. He never uses float since he don't need it. The datasheet of the DS18B20 shows at page 6, how the data is formatted:




The 4 highest bits just resemble the sign bit 11.
The first digit with full degrees is bit 4. Every bit below that has values below 1°C


So the data bytes 0b1111100001010000 will represent a temperature of -123°C and 0b1111100001011000 -122.5°C.

The author from the link then shifts this data 4 bits to the right, so that all bits representing values under 1 vanish. You can convert the received value per hand to float by also using this.

int16_t whole_degree = (result &amp; 0x07FF) &gt;&gt; 4;
float temperature = whole_degree + 0.5*((data[0]&amp;0x8)&gt;&gt;3) + 0.25*((data[0]&amp;0x4)&gt;&gt;2) + 0.125*((data[0]&amp;0x2)&gt;&gt;1) + 0.625*(data[0]&amp;0x1);
if (data[1]&amp;128) temperature*=-1;


As float does not have the same structure, as the data, we need to convert them. So I calculate first the number of whole degrees analog the your code. Then I add this up with the values of the lowest 4 bits. ((data[0]&amp;0x8)&gt;&gt;3) and it's siblings will be 1, when the corresponding bit is set, and 0, if not.

So you get the full precision of the sensor (12 bits). Please note, that for this to work, you should not configure the sensor to less resolution. In that case you would have to ignore the corresponding lowest bits. But the sensor is in 12 bit mode at power up anyway and your code does not configure it otherwise.

Note: I'm unsure about the line result |=61440; in the original code. This sets the 4 highest bits of a 16 bit value to 1. I don't see, why this should be correct here, since a normal 16bit integer does only have 1 sign bit. In my understanding the original code would lead to false readings (way off), when reading temperatures below zero. I instead simply multiplied the resulting temperature with -1.

The whole code would look like this (I also added the statement for printing out the pure received data as binary, as I requested it in my comment. These statements are currently commented out):

#include &lt;OneWire.h&gt;
float dallas(int x,byte start){
    OneWire ds(x);
    byte i;
    byte data[2];
    int16_t result;
    float temperature;
    do{
        ds.reset();
        ds.write(0xCC);
        ds.write(0xBE);
        for (int i = 0; i &lt; 2; i++) data[i] = ds.read();
        result=(data[1]&lt;&lt;8) |data[0];
        // Here you could print out the received bytes as binary, as requested in my comment:
        // Serial.println(result, BIN);
        int16_t whole_degree = (result &amp; 0x07FF) &gt;&gt; 4; // cut out sign bits and shift
        temperature = whole_degree + 0.5*((data[0]&amp;0x8)&gt;&gt;3) + 0.25*((data[0]&amp;0x4)&gt;&gt;2) + 0.125*((data[0]&amp;0x2)&gt;&gt;1) + 0.625*(data[0]&amp;0x1);
        if (data[1]&amp;128) temperature*=-1;
        ds.reset();
        ds.write(0xCC);
        ds.write(0x44, 1);
        if (start) delay(1000);
    } while (start--);
    return temperature;
}
void setup{
  //Adding Serial.begin(9600); for printing the received bytes here
  //Serial.begin(9600);
  dallas(A0,1);
}
void loop{
  float currentTemp = dallas(A0,0);
}