Java Double to doubleToUnary(int max, double num)

Here you can find the source of doubleToUnary(int max, double num)

Description

double To Unary

License

Open Source License

Declaration

public static char[] doubleToUnary(int max, double num) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static char[] doubleToUnary(int max, double num) {
        char[] chars = new char[max];
        int discrNum = (int) num;
        // Fill with ones
        for (int i = 0; i <= num; ++i) {
            chars[i] = '1';
        }/*from  w  w w . jav a  2 s.  co  m*/
        // Fill with zeros
        for (int i = discrNum + 1; i < max; ++i) {
            chars[i] = '0';
        }
        return chars;
    }
}

Related

  1. doubleToSexagesimal(double value, int precision, double hopr, double lopr)
  2. doubleToSingleQuote(String source)
  3. doubleToSingleQuotes(String str)
  4. doubleToSlider(final double min, final double max, final double value)
  5. doubleToTime(double time)