Home Answers Viewqa IDE-Questions program binary

 
 


Stephen lam
program binary
2 Answer(s)      a year and 11 months ago
Posted in : IDE Questions

Hi

I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please

Thks

View Answers

June 24, 2011 at 10:39 AM


Try this:

program decimalToBinary;

const v:array[0..7] of byte=(1,2,4,8,16,32,64,128); {powers of 2}
      bin:array[false..true] of char='01';
      oct:array[0..7] of char='01234567';

{Decimal to binary}
function dec2bin(b:byte):string;
 var s:string;
     i:byte;
 begin
  s:='';
  for i:=7 downto 0 do
   s:=s+bin[(v[i] and b=v[i])];
  dec2bin:=s;
 end;

June 29, 2011 at 10:47 PM


Many Thanks

Will try it

Rgds









Related Pages:
binary
binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. Thks
program binary
program binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
BINARY TO DECIMAL - Java Beginners
BINARY TO DECIMAL  HELP ME PLSS. PROGRAM THAT CONVERTS BINARY TO DECIMAL  Hi friend, Program to convert Binary To Decimal : import... (System.in); System.out.print ("Enter a binary number "); String str
Binary to decimal - Java Beginners
Binary to decimal  Need help pls.. i cannot run this program... pls correct my program... i really appreciate your answers... thank you very mucha... = Integer.parseInt(JOptionPane.showInputDialog("Input Binary:")); String c = args[0
JAVA: Recusrion, Binary Search
JAVA: Recusrion, Binary Search  I want to learn about Binary Search..., Inheritance, Interface, etc for this program. I also know that this needs to be implemented into a lot of classes. So if you could figure out this program for me
binary search - Java Beginners
binary search  Write a java program to search an array by using recursive binary search.  /* * To change this template, choose Tools... program public static void main( String [ ] args ) { int SIZE
Convert Text to Binary
Convert Text to Binary       In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text to Binary
Convert Text to Binary
to Binary. The following program provides you the functionality to convert Text to Binary. Code Description: In the program code below, to take the input from... Convert Text to Binary      
Convert Number to Binary
binary. Code Description: This program takes a decimal number at the console... Convert Number to Binary       In this section, you will learn to convert a number to a binary (0,1
Convert Decimal into Binary
into binary. The java.lang package provides the functionality to convert  a decimal number into a binary number.  Description of program: This program... of binary number is 2. Here is the code of this program
Convert Binary to Hexadecimal
the binary data into hexadecimal.  Description of the program: This program takes... '0' or '1' , program converts the binary data into hexadecimal using... Convert Binary to Hexadecimal     
Binary search tree (insertion) urgent!!
Binary search tree (insertion) urgent!!  Create a program to construct a binary search tree consisting of nodes that each stores an integer.... Assume a binary search tree is constructed from the values 14, 35, 2, 3, 39
Java Write To File Binary
Java Write To File Binary In this tutorial you will learn how to write to binary file. A binary file is a file into which the bit patterns of mostly data types can be formed to a byte of 8 bits. Write to a binary file in java
Java binary to decimal
Java binary to decimal       This Tutorial helps you to know the code for Java binary... you in understanding a how to get a 'Java binary to decimal'. For this we have
Convert Hexadecimal into Binary and Long
into the binary and long. At run time this program asks for a  a hexadecimal data... Convert Hexadecimal into Binary and Long   ... the hexadecimal data into the binary and long format. The java.lang package provides
I converting binary to decimal and vice versa
I converting binary to decimal and vice versa  can i ask for the codes in converting binary to decimal and decimal to binary to be run in one program with repeat.. pls. help me! i badly need the codes by monday!! pls
Convert Binary to Decimal
Convert Binary to Decimal       In this section, you will learn how to convert a  binary... to convert the integer data into the binary to decimal.  Code Description
Java binary tree code
Java binary tree code       Binary Tree are the specialized tree that has two possible branches... especially in mathematics and Boolean. The java binary tree find its application
Reading binary file into byte array in Java
Example code of reading binary file into byte array in Java This example shows you how to read a binary file into byte array from Java program. This type... of the Java program that reads the binary file into byte array: import java.io.
Java binary tree insert
Java binary tree insert       The Binary Tree insert is specialized use of binary tree... node insert right to this root node. This module implements a binary search tree
Binary Search in Java
Binary Search in Java is used to search an element from an array. Programmers opt for Binary search over linear search when it comes to large numbers. It can be done either recursively or iteratively. The program checks the entered
Binary tree
Binary tree  a. Construct a method to implement a binary tree using an array. b. Implement the binary tree to store numbers in sorted order
Convert integer type data into binary, octal and hexadecimal
into binary, octal, and hexadecimal. The following program helps you to convert... Convert integer type data into binary, octal and hexadecimal... will learn how to convert an integer type data into binary, octal and hexadecimal
Binary tree
Binary tree  hii, What is binary tree?   hello, A binary tree is a tree in which every node has exactly two links i.e left and right link
binary tree
binary tree  can a binary tree be implemented with out comparing...://www.roseindia.net/java/java-get-example/java-binary-tree-code.shtml http://www.roseindia.net/java/java-get-example/java-binary-tree-insert.shtml
binary tree
binary tree  how to count no. of nodes in a binary tree for mlm if it complet tree or incomplet tree in php using mysql db
octal to binary
octal to binary  i want to know how to convert a octal to binary number   Here is a java example that converts octal to binary. import... binary=Integer.toBinaryString(i); System.out.println(binary
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
c program
c program  How to convert binary digits to decimal number without using power function
universal binary for ipad iphone
universal binary for ipad iphone  How can i create a universal binary for iPad and iPhone
Binary Search on array
Binary Search on array  What requirement is placed on an array, so that binary search may be used to locate an entry? â?º The array elements must form a heap. â?º The array must have at least 2 entries. â?º The array must
Java read binary file
Java read binary file  I want Java read binary file example code that is easy to read and learn. Thanks   Hi, Please see the code at Reading binary file into byte array in Java. Thanks   Hi, There is many
binary search tree
binary search tree  Construct a binary search tree by inserting words into an empty tree. "cut your coat according to your cloth" Visit the tree using all three traversal algorithms and list the output sequence for each algorithm
binary search tree
binary search tree  Construct a binary search tree by inserting the following sequence of characters into an empty tree. N O N L I N E A R D A T A Visit the tree using all three traversal algorithms and list the output sequence
java binary file io example
java binary file io example  java binary file io example
Parsing Binary Data in PHP - PHP
Parsing Binary Data in PHP  Is there a better library for working with binary data in PHP
send Binary Data by doGet or doPost?
send Binary Data by doGet or doPost?  which method in doGet or doPost is use to send binary date to server
Binary Search Tree
Binary Search Tree  Question-1 ) Modify the BinarySearchTree class so that the iterators are fail-fast.Test your class with amain method ? Question-2 ) Modify the BinarySearchTree class so that the BinarySearchTree objects
Binary Search Tree
Binary Search Tree  Question-1 ) Modify the BinarySearchTree class so that the iterators are fail-fast.Test your class with amain method ? Question-2 ) Modify the BinarySearchTree class so that the BinarySearchTree objects
binary distributions - Java Server Faces Questions
binary distributions  what are binary distributions
binary search tree
binary search tree  how can i make binary search tree? i want write a code that make dictionary with binary search tree data structure.please help me?   class bnode { String key; bnode left; bnode right
Binary Search!!! - Java Beginners
Binary Search!!!  Hi Sir, My question is quite simple. im only getting "ArrayIndexOutOfBoundsException : 10" in the if statement which is inside the 1st while loop. How can i get rid of it? The if statement is btw
Java Convert Octal to Binary
Java Convert Octal to Binary In this tutorial, you will learn how to convert octal to binary. Java has provide different ways to change the number system of different numbers. You can convert and decimal to octal, decimal to binary
parse a file into primitive binary format
parse a file into primitive binary format  Hi, I need help converting an audio file or any other file to its primitive binarty format, and when I read the inputstream I find it some integers and I don't know its binary

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.