This article reprinted http://www.cnblogs.com/chengmo/archive/2010/10/14/1851570.html, thanks to the author!The shell can represent different binary data without invoking a 3rd party command. Here is a summary of the presentation methods. The default value of the shell script is handled by a 10 binary number, unless the number is preceded by a particular notation or prefix. To represent other binary type values. such as: Starting with 0 is the 8 binary. Starting with 0x is the 16 binary number.
Import Java.util.Scanner;/** Write method to convert octal number to decimal number. Integer.valueof ("876", 8). ToString ()* */Public class Octaltodecimal { Public static void Main (string[] args) { String OldValue;System. out. Print ("Input of the An octal number:"); oldValue = new Scanner (System. IN). Next (); String newvalue;newvalue = Octaltodecimal.todecimal (oldValue);System. Out.print (newval
Octal to hexadecimal, hexadecimal
InputThe first act is an integer T, indicating the number of data groups.
There is an octal numeric string per line in Line T.
OutputThe hexadecimal string corresponding to each group of data output
Sample Input4
7
77
233
2333333333333333333
Sample Output7
3F
9B
9B6DB6DB6DB6DB
Code:
# Include # Include Using namespace std;Char x (int n ){If (n Return n + '0 ';Switch (n
(stringInputintTypeofinput,inttypeofoutput) - { in intValue =Convert.ToInt32 (input, typeofinput); - stringres =convert.tostring (value, typeofoutput); to + returnRes; - } the * $ Private voidBtn8_16_click (Objectsender, EventArgs e)Panax Notoginseng { -Textboxofoutput.text = Convertnumber (Textboxofinput.text,8, -); the } + } A}3 ShowIn order to verify the correctness of the program, I took steps to convert the
Decimal Turn binary:Decimal to Binary #includeDecimal Turn octalDecimal to octal # include Decimal to Random binary:Decimal conversion to discretionary source code # include Eight hexadecimal output via library function:#include pre> C + + binary conversion (decimal to binary, octal, discretionary)
) {System.out.print ("0");return; //Return here and end this method when the received data is 0.}while (num! = 0) {int x = num 15;ARR[--P] = chs[x]; //In the process of saving, starting from the highest bit. This is the first number to be calculated, and the last one to be stored in the array.num = num >>> 4; //Move num to the right by 4 2 binary bits. >>> code unsigned Right shift. >> represents a signed shift.}for (int i=p;iSystem.out.print (Arr[i]);}}End GethexStart Getoctalpublic static
In my impression, it is a very common problem to convert to one another, so in Python, naturally, the following code should be util.
This is an online search from a also can be a python conversion, verified to be used. Its implementation code is posted below:
#!/usr/bin/env python #-*-coding:utf-8-*-# 2/10/16 base Trans. wrote by Srcdog on 20th, April, 2009 # LD elements
In base 2, 10, 16. Import Os,sys # global definition # base = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F] base =
details they may produce may be even more terrible: A large number of small spaces, each containing a small number of triangles, and these triangles may belong to multiple materials and textures. Compared with these disadvantages, the advantages of allowing a large space change are like chicken ribs, which makes no sense at all.
However, this is, after all, a "abnormal" World, and in a "abnormal" world, any "correct" approach is wrong. Therefore, we may also be forced to use it like this.Algor
Topic Links:id=1131 "target=" _blank ">click here~Although Java simulates water over, I see someone's wonderful code, posted and shared with you.Import java.math.*;import java.util.*;class main{public static void Main (String args[]) {Scanner cin = new Scanner (System. in); BigDecimal Eight = new BigDecimal (8), while (Cin.hasnext ()) {String num;num = Cin.nextline (); BigDecimal ans = new BigDecimal (0); BigDecimal tmp = new BigDecimal (1), for (int i = 2;i The algorithm is to convert division
The Code is as follows:Void bresenham_circle (CDC * PDC, int ox, int Oy, int R) {float d = 1.25-R; int x = 0, y = r, FX = r/1.4; while (X! = FX) {If (d Dot bresenham algorithm rasterized circle (octal method)
1. Use the basic operation of the stackThe code is implemented as follows#ifndef _seqstack_h#define _seqstack_h#includeBOOL Isfull (Stack *st) {return st->top >= st->capacity;} BOOL IsEmpty (Stack *st) {return st->top = = 0;} void Initstack (Stack *st) {st->base = (Elemtype *) malloc (sizeof (elemtype) *stack_init_size); assert (st->base! = NULL); st->capacity = Stack_init_size;st->top = 0;} void Converseq (int n) {Stack s; defines a stack int x = 0; X is used to save the remainder initstack
Convert decimal to hexadecimal:Integer. tohexstring (int I)Decimal to octalInteger. tooctalstring (int I)Convert decimal to binaryInteger. tobinarystring (int I)Hexadecimal to decimalInteger. valueof ("ffff", 16). tostring ()Octal to decimalInteger. valueof ("876", 8). tostring ()Convert binary to decimalInteger. valueof ("0101", 2). tostring ()Is there any way to directly convert 2, 8, and 16 to 10?Java. Lang. Integer classParseint (string S, int Rad
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.