import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
    public static String padLeftZeros(String inputString, int length) {
        if (inputString.length() >= length) {
            return inputString;
        }
        StringBuilder sb = new StringBuilder();
        while (sb.length() < length - inputString.length()) {
            sb.append('0');
        }
        sb.append(inputString);
    
        return sb.toString();
    }

    public static void main(String[] args) {
        float num = 0.751220f;

        // get the bits of the float into an integer
        int bits = Float.floatToIntBits(num);
        
        // get binary representation of numBits
        String bin = Integer.toString(bits, 2);
        
        // since a float occupies 32 bits, pad with upto 32 zeroes
        String binaryRep = padLeftZeros(bin, 32);

        System.out.println(binaryRep);
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: