Skip to content
Advertisement

Tag: binary

Addition of two given numbers

Basically is about the binary numbers, the user needs to input two random numbers, both numbers will be added, and the addition of those two numbers only needs to have ones and zeros for example 5+6==11 OR 55+55=110, then throw a message saying “the addition only has 1’s and 0’s, otherwise for example 25+46=71 or 575+575=1150 then a message saying

decimal value of the number formed by concatenating the binary representations of first n natural numbers

Given a number n, find the decimal value of the number formed by concatenating the binary representations of first n natural numbers. Print answer modulo 10^9+7. Also, n can be as big as 10^9 and hence logarithmic time approach is needed. Eg: n=4, Answer = 220 Explanation: Number formed=11011100 (1=1,2=10,3=11,4=100). Decimal value of 11011100=”220″. The code I am using below

change binary to decimal

I have to write a method that changes binary to decimal. Write a method that will convert the supplied binary digit (as a string) to a decimal number. convertToDecimal(“01101011”) = 107 convertToDecimal(“00001011”) = 11 i have created it to change decimal to binary however im not sure how to create it binary to decimal. Answer

Convert Long to DateTime from C# Date to Java Date

I’ve been trying to read the binary file with Java, and the binary file is written in C#. And some of those data is contain a DateTime data. When DateTime data will be written into the file (in binary), it using DateTime.ToBinary(); on C#. For reading the DateTime data, it will convert first from bytes into long data, using BitConverter.ToInt64(byte[],

Converting Decimal to Binary Java

I am trying to convert decimal to binary numbers from the user’s input using Java. I’m getting errors. How do I convert Decimal to Binary in Java? Answer Your binaryForm method is getting caught in an infinite recursion, you need to return if number <= 1:

First occurrence in a binary search

I’m tinkering with some code and I realized something I never knew. A normal binary search will return a random index in a data set for a key that occurs more than once. How can I modify this code below to return the first occurrence? Is this something people do? Answer Having found a matching value, you basically need to

How to check whether the file is binary?

I wrote the following method to see whether particular file contains ASCII text characters only or control characters in addition to that. Could you glance at this code, suggest improvements and point out oversights? The logic is as follows: “If first 500 bytes of a file contain 5 or more Control characters – report it as binary file” thank you.

Advertisement