• No results found

The binhex.tex package for expansible conversion into binary-based number systems

N/A
N/A
Protected

Academic year: 2021

Share "The binhex.tex package for expansible conversion into binary-based number systems"

Copied!
2
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The binhex.tex package for expansible

conversion into binary-based number systems

David Kastrup

July 22, 2005

Contents

1 Usage 1

1

Usage

This is a file for expandably converting numbers into binary, octal and hexadec-imal. All constructs TEX accepts as an argument to its \number primitive are valid. This holds for all numeric arguments of the macros presented in here.

You use this package by simply inputting it with

\input binhex

It will work equally well under LATEX and plain TEX. It does not even use plain

TEX, but only TEX primitives. Simply setting the correct \catcode values for {}# and end of line will make it load and work under iniTEX.

The following macros are defined: \binary{hnumber i} will convert hnumber i

\binary

into its binary representation.

\binary{0} → 0

\binary{\maxdimen} → 111111111111111111111111111111 \binary{-"7EE6} → -111111011100110

\nbinary{hsizei}{hnumber i} will convert hnumber i into a binary

representa-\nbinary

tion of at least hsizei digits length, filling up with leading zeros where necessary. The - sign of negative numbers is not counted. If both hsizei and hnumber i are zero, an empty string is generated. This should please some computer scientists in some situations.

\nbinary{3}{3} → 011 \nbinary{3}{-2} → -010 \nbinary{3}{-12} → -1100

\hex{hnumber i} converts hnumber i into its hexadecimal representation, using

\hex

David.Kastrup@neuroinformatik.ruhr-uni-bochum.de

(2)

uppercase letters.

\hex{34} → 22

\hex{-4711} → -1267

\nhex{hsizei}{hnumber i} will convert hnumber i into a hexadecimal

represen-\nhex

tation of at least hsizei digits length, filling up with leading zeros where necessary. The - sign of negative numbers is not counted. If both hsizei and hnumber i are zero, an empty string is generated. This should please some computer scientists in some situations.

\nhex{3}{3} → 003 \nhex{3}{-\maxdimen} → -3FFFFFFF

\oct{hnumber i} converts hnumber i into its octal representation.

\oct

\oct{34} → 42

\oct{-4711} → -11147

\noct{hsizei}{hnumber i} will do the right thing.

\noct

\noct{3}{13} → 015

\noct{3}{-\maxdimen} → -7777777777

\tetra{hnumber i} is for people counting with arms and legs instead of fingers,

\tetra

or for quadrupeds.

\tetra{34} → 202

\tetra{-4711} → -1021213

\ntetra{hsizei}{hnumber i} is for those of the same count which have

mini-\ntetra

mum requirements.

\ntetra{3}{3} → 003

\ntetra{3}{-\maxdimen} → -333333333333333

\nbinbased{hlogbasei}{hsizei}{hnumber i} will convert hnumber i into

num-\nbinbased

ber base 2hlogbasei and generate at least hsizei digits. Only supported values of hlogbasei are 1, 2, 3, 4. This is called by all other macros except of the faster binary conversion macros.

\nbinbased{3}{3}{13} → 015

\nbinbased{3}{3}{-\maxdimen} → -7777777777 \nbinbased{2}{4}{13} → 0031

\nbinbased{2}{4}{-\maxdimen} → -333333333333333

That’s it, have fun!

Referenties

GERELATEERDE DOCUMENTEN

For the road sign recognizer the binary partition tree is used to segment the image in regions that have the same color.. The purpose of this step is the capture the

This model is then simu- lated and the computer produces a graph or a table with the outcomes of the model” (p.2). Het model kan gerepresenteerd worden door een plaatje of door

4 3 コード 4 1 はじめに ascmac パッケージは、L A TEX 2ε の標準機能の範囲で、図や罫線で囲んだボックス

Assigns a value to a LaTeX hcounteri previously initialized with \newcounter. This command is similar in concept and syntax to \setcounter except for two major differences. 1)

you no longer wish to re-generate your MetaPost figures, the package can be given the compilation=off option to save compilation time:.. \usepackage

The NotesPages package provides one macro to insert a single notes page and another to fill the document with multiple notes pages, until the total number of pages (so far) is

There hnumberi is prefixed with the necessary amount of zeros to result in a number exactly nine digits long: For the digit one (resulting from the nested \ifnums), eight leading

\l__unravel_setup_restore_tl This token list variable will contain code to restore category codes to their value when the package was loaded.. 20 \gdef \l__unravel_setup_restore_tl {