Here you can find the source of getBinary(long input)
public static Stack<Integer> getBinary(long input)
//package com.java2s; /**/* ww w .ja v a2 s. com*/ * OpenCPS is the open source Core Public Services software * Copyright (C) 2016-present OpenCPS community * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ import java.util.Stack; public class Main { public static Stack<Integer> getBinary(long input) { Stack<Integer> binaryStack = new Stack<Integer>(); while (input != 0) { binaryStack.push((int) input % 2); input = input / 2; } return binaryStack; } }