Absolute beginners TF map making by Grimm

copied from here
TF Map Making Tutorial
[ BackHomeD/L Tutor ]
The Team Fortress Map Making Tutor. v1.1
by: grimm [502]


INDEX

0.0 New Since v1.0

1. Basic intro

1.1 Introduction
1.2 File Listing
1.3 What is TF?
1.4 How do I make a TF map?

2. Entity specifics

2.1 Tool & trick of the trade
2.2 TF Entities
2.3 info_tfdetect
2.4 info_player_teamspawn
2.5 info_tfgoal
2.6 item_tfgoal
2.7 info_tfgoal_timer

3. EXAMPLE1.MAP

3.1 the example map
3.2 what we need
3.3 the scoring system
3.4 the crates
3.5 the ladder

4.0 Conclusion

Appendix 1. Bitfields

Appendix 2. Decimal/Binary conversion -Jon Zorn [502]

 


1.1 INTRODUCTION:

This tutorial is not aimed to explore all the facets behind the mapmaking process. Mapmaking is a technical process, but is also subject to a great deal of artistic influence. It is understood that the reader should already possess some basic mapmaking skills in order to comprehend the various terms and techniques described herein.

The tutorial will in the most part deal with the heart and soul of the TF map, which lies in the entities.

This text should be used in conjunction with the EXAMPLE1.MAP file, which is a special sample map containing everything the reader needs to follow this text!

I would appreciate your comments and suggestions. The wave of interest is definitely shifting towards QUAKE2 and the impending arrival of TF2 but your comments can keep this work alive. Feel free to contact me.


1.2 FILE LISTING

You should have the following files, in order to take full advantage of this tutorial. If you downloaded the 502TUTOR.ZIP archive, these files should all be contained within.

tutor.txt the file you are currently reading.
EXAMPLE1.MAP the .map file so the reader can follow and even experiment in, with their favorite map editor.
readme.txt copyright & distribution MUST READ!

 


1.3 WHAT IS TF?

Team Fortress is a special patch for ID Software’s hit game Quake. The people working at Team Fortress Software have done excellent work with their patch, giving players from around the world, a new and dazzling arena of play! Players can choose between the 9 available player classes, each being individualised by their diversified weaponry and skills. For more detailed and accurate information concerning the work of Team Fortress Software, please visit the following sites:

http://www.planetquake.com/teamfortress/
http://www.teamfortress.com


1.4 HOW DO I MAKE A TF MAP?

What is the difference between a normal map, and a Team Fortress map? Unlike most will initially think, the changes needed to be done to a map, in order to make it into a TF map are very minor. The complexity of the entity work needed to be done to your map can roughly be calculated by the complexity of your scoring system.

A great deal of people are very confused by the simplicity of this answer. The only thing you need to do, to make a normal quake map, into a TF specific level is include the proper ENTITIES! But most budding mapmakers just want to start with a basic Capture the Flag scheme, in order to get a better feel for the whole mapmaking process.

This is what this tutorial and the EXAMPLE1.MAP will cover, it is just a very basic map, in which the player selects his team & class, and can take and capture the flag. The flag immediately returns to its point of origin.


2.1 TOOL & TRICK OF THE TRADE

Many tools are available to mapmakers, to accomplish many tasks! But when it comes to making TF maps, the most valuable and downright usefull tool for the beginner mapmaker has got to be ENTed.

What is an ENTed, what does it eat?

ENTed is an Quake Entity Editor, it is also specifically aimed to be used with TF Entities. You can easily load up a .map file to view and edit the existing entities. It has a very simple and efficient interface and you cannot continue in this tutorial without it. You can get ENTed from the official ENTed site:

http://www.erinyes.com/ented/

You can view and edit the entities directly from the .map file using a regular text editor. But your thinking, how does that help me figure out how a specific map author got a certain effect, if they don’t make their .MAPs public. But that is the big surprise! You can also do the same with the .BSP file! That’s right, just open up your favorite map in WORDPAD (my usual text editor runs out of memory..) and go towards the end of the file, you will see a string of variables that are completely legible. Those are the entities and all their attributes.

It is considered good manners not to simply copy someone else’s work without their permission.


2.2 TF ENTITIES

There are 5 TF entities that can be set to produce hundreds of effects. If you do not know what an entity is, you should begin by taking a look at a mapmaking tutorial, which will explain what entities are, and how they are used in maps. The 5 Team Fortress entities are:

info_tfdetect
info_player_teamspawn
info_tfgoal
item_tfgoal
info_tfgoal_timer

The following entity information will not go into explicit detail, concerning the entities. If you wish to read more in depth information, you should consult the following two files:

TFORTMAP.TXT
TFENTREF.TXT

In each specific entity detail section below, you will see a copy of the entities as they are represented in the EXAMPLE1.MAP in order to explain only the aspects pertaining to this tutorial.

You should, in every case, also look at the entities through ENTed, you will see that ENTed provides you with a structured and controlled environment from which to fiddle with the entities. But it also becomes time consuming to use ENTed, once you really get the hang of entity work. But ENTed is always usefull when you don’t want to go looking through entity reference sheets for specific bitfields and such. But we’ll explain all that later.


2.3 info_tfdetect

“TeamFortress maps will be automatically detected by theTeamFortress patch if you put an entity in the map with a classname of “info_tfdetect”. This makes TeamFortress automatically turn on the FORTRESSMAP toggleflag, and turn on teamplay.

Also, once the TeamFortress map has been detected, the patch will look for any spawnpoints dedicated to teams (see below). If it finds any, it will look for the highest team number that is used. Once found, it will limit anybody attempting to join a team to that number. At the moment, Maps are limited to a maximum of 4 teams. E.g. If the highest team number used by a Team Spawnpoint is 3, then the patch will only allow players to join teams 1, 2, and 3.” –Robin Walker TF Software _tfortmap.txt_

 

This entity appears only once, in every TF map. Here is the info_tfdetect variable along with its attributes, as found in the EXAMPLE1.MAP file.

{
“classname” “info_tfdetect”
“hook_out” “1”
“impulse” “4”
“team_broadcast” “SELECT YOUR TEAM\n\n1- BLUE TEAM\n2- RED TEAM\n\nEXAMPLE1.MAP BY GRIMM [502]\nFCO@VIF.COM\n”
“origin” “616 96 -312”
}

classname: is simply the entity type name. That is how you can tell what sort of entity your dealing with. In this case there is only ONE info_tfdetect entity possible on the map. But do not be surprised if you see many with the same name.

there are other attributes we will see, that will give us the ability to distinguish between every entity.

hook_out: this variable controls the availability of the grappling hook in the level. If set to 1, it will NOT be available on the level.

impulse:

 1  ClasSkin Off/On
 2  ClassPersistence Off/On
 4  CheatChecking Off/On
 8  FortressMap Off/On
 16  RespawnDelay See N.B.
 32  RespawnDelay See N.B.
 64  AutoTeam Off/On
 128  Individual Frags Off/On

FortressMap will be set On automatically by the the Detection entity anyway, so just ignore that Bit.

N.B. The RespawnDelay settings takes 2 bits. The value of both of them determines the level of respawn delay, as follows:

 Bit 5  Bit 6  Result
 Off  Off  No Respawn delays
 On  Off  5 Second respawn delay
 Off  On  10 Second respawn delay
 On  On  20 Second respawn delay

team_broadcast: String that replaces the team selection menu. Try removing this line, see what it does. I think most people just never knew you could leave it out if you wanted just the generic team selection menu.

origin: this line holds the exact coordinates of the entity within the map. don’t fiddle with this. If you end up putting an entity in the ‘void’ you will have problems compiling. Finding that one displaced entity is a pain in the ass if you aren’t used to the coordinate system in your map editor.


2.4 info_player_teamspawn

“There is now a new entity for Team Spawnpoints. Team Spawnpoints are used to make players only spawn in points designated for their team. Use it to make players spawn inside their own base/fortress.”-Robin Walker._tfortmap.txt_

There are two ‘info_player_teamspawn’ entities in the EXAMPLE1.MAP file. It just so happens I had decided to make the example map different from most, by including more than 1 team being able to both take the same flag, and capture it at the same point. But I won’t list the entity information twice, since the only differences are the origin and ‘team_no’ variables.

{
“classname” “info_player_teamspawn”
“angle” “180”
“netname” “team2_spawn”
“team_no” “2”
“origin” “256 384 -288”
}

classname: is simply the entity type name. That is how you can tell what sort of entity your dealing with.

angle: the angle of direction this entity is facing. in most cases this value is not usefull, but having players spawn facing a wall can give people some flashbacks of reform school. All that anger makes for very messy play. So use this value well.

netname: variable used to assign a distinctive name to an entity. ENTed uses this value.

team_no: Only players on the specified team can spawn at this location.

origin: this line holds the exact coordinates of the entity within the map. don’t fiddle with this.


2.5 info_tfgoal

The goal entities are the most interesting and versatile entities of the bunch. A goal entity works like an alarm system sensor, unless de-activated, it is constantly trying to determine whether or not the detection criteria are met; and consequently react in the specified manner.

A very simple use of an info_tfgoal is an entity placed where a player will activate it, for example a doorstep. You can have it centerprint to his screen a message like ‘welcome’.

Even a very simple thing as this, can be made more complex. For instance, you decide it will only say ‘welcome’ to players of a specific team. Why not play a sound file instead of the message etc..

If you wish to get a more detailed description of everything a goal can do, you should consult the tfortmap.txt. In this tutorial, we will stick to the basics, and I will explain how I used two goal entities for two completely different effects.

The first of the goals is the trickier one. It is the flag capture goal. In every map you’ve played where there was a flag drop area, sniper tower in 2fort4. There is an invisible entity right over that slightly raised floor portion you drop to flag to. I would be kind of hard to find out where you had to bring the flag unless you have a marker on your map to designate such a special area. In most maps, the flag dropoff is on the ground, as a matter of personal preference, I put the one in the EXAMPLE1.MAP on the wall.

I think it’s important to state that the flag itself is also a goal. But due to the fact that it can be picked up and moved by players, it is an ‘item_tfgoal’. The following goals cannot be moved by players, although they CAN be removed by other goals. In this example map, I stated that ANY team can bring the flag back to this point. In your map, you will have to have both the flag and dropoff entities for each team in your map for a standard Capture The Flag scenario.

{
“classname” “info_tfgoal”
“netname” “Flag Capture”
“goal_activation” “1”
“items_allowed” “1”
“axhitme” “1”
“message” “You have captured the flag!\n”
“increase_team1” “10”
“frags” “12”
“goal_effects” “1”
“origin” “-104 64 -16”
}

classname: is simply the entity type name. That is how you can tell what sort of entity your dealing with.

netname: variable used to assign a distinctive name to an entity. ENTed uses this value.

goal_activation: Determines how the Goal is activated. Bitfields.
1 : Activated when touched by a player.
2 : Activated when touched by a detpack explosion.
4 : Only activated if the AP fails Criteria.

items_allowed: AP needs this GoalItem to meet this Goal’s criteria.

axhitme: Goal removes this GoalItem from APA that has it.

message: This is a message that will be centerprinted to the AP (Affected Player) only.

increase team # : This value will be added to the team #’s frag count. This does not include the AP. So make sure you have a ‘frags’ line to add the points to the capturing player also!

frags: This value will be added to the APA (All Players Affected) frag count.

goal_effects: Determines what players are affected. Bitfields.
1 : AP is affected.
2 : Everyone on the AP’s team is affected.
4 : Everyone not on the AP’s team is affected.
8 : Everyone except the AP is affected.
16 : Radius effect does not go
through walls.

origin: this line holds the exact coordinates of the entity within the map. don’t fiddle with this.


{
“classname” “info_tfgoal”
“mdl” “progs/backpack.mdl”
“netname” “re-supply_pack”
“goal_effects” “1”
“armortype” “0.8”
“armorvalue” “300”
“health” “25”
“ammo_shells” “50”
“ammo_nails” “50”
“ammo_rockets” “50”
“ammo_cells” “50”
“ammo_medikit” “50”
“no_grenades_1” “1”
“no_grenades_2” “1”
“goal_activation” “1”
“message” “Up And At Them!\n”
“wait” “20”
“origin” “-16 480 -192”
}

classname: is simply the entity type name. That is how you can tell what sort of entity your dealing with.

mdl: The mdl used by this Goal. UNSPECIFIED = INVISIBLE

netname: variable used to assign a distinctive name to an entity. ENTed uses this value.

goal_effects: Determines what players are affected. Bitfields.
1 : AP is affected. (default)
2 : Everyone on the AP’s team is affected.
4 : Everyone not on the AP’s team is affected.
8 : Everyone except the AP is affected.
16 : Radius effect does not go through walls.

armortype : Use negative values to remove armor % reduction

Red Armor = 0.8
Yellow Armor = 0.6
Green Armor = 0.3

armorvalue : Use negative values to remove armor

health : Health Added to affected parties. Use Negative values to HURT players.

ammo_shells : Shells Added. Use Negative values to remove ammo.

ammo_nails : Nails Added. Use Negative value to remove ammo.

ammo_rockets : Rockets Added. Use Negative value to remove ammo.

ammo_cells : Cells Added. Use Negative value to remove ammo.

ammo_medikit : MediKit Added. Use Negative value to remove ammo.

no_grenades_1 : Type 1 Grenades Added. Use Negative value to remove from player.

no_grenades_2 : Type 2 Grenades Added. Use Negative value to remove from player.

goal_activation: Determines how the Goal is activated. Bitfields.
1 : Activated when touched by a player.
2 : Activated when touched by a detpack explosion.
4 : Only activated if the AP fails Criteria.

items_allowed: AP needs this GoalItem to meet this Goal’s criteria.

axhitme: Goal removes this GoalItem from APA that has it.

message: This is a message that will be centerprinted to the AP (Affected Player) only.

frags: This value will be added to the APA (All Players Affected) frag count.

goal_effects: Determines what players are affected. Bitfields.
1 : AP is affected.
2 : Everyone on the AP’s team is affected.
4 : Everyone not on the AP’s team is affected.
8 : Everyone except the AP is affected.
16 : Radius effect does not go through walls.

origin: this line holds the exact coordinates of the entity within the map. don’t fiddle with this.


2.6 item_tfgoal

“classname” “item_tfgoal”
“goal_activation” “693”
“skin” “3”
“mdl” “progs/tf_flag.mdl”
“netname” “theflag”
“goal_result” “16”
“pausetime” “10”
“message” “You have the flag!\n return it to the Blue wall return\n”
“goal_no” “1”
“goal_effects” “1”
“delay” “10”
“items” “131072”
“origin” “256 320 80”

 

classname: is simply the entity type name. That is how you can tell what sort of entity your dealing with.

goal_activation : Bitfields
1 : Carrying Player glows.
2 : Carrying Player moves at half speed.
4 : Item is dropped when a player with it dies.
8 : Item is returned when dropped.
16 : Item is returned when removed from players by a Goal
32 : Item is returned due to “pausetime” (see below)
64 : Only activated (picked-up) if AP fails Criteria.
128 : Enable “pausetime” removing.
256 : Players keep this item when they die.
512 : If this Item isn’t being carried, it glowsdimly.
1024: Don’t remove the results of this Item when it’s removed from a player.
2048 : If this bit is set, the GoalItem drops to the ground when it first spawns.
8192 : If this bit is set, the GoalItem is Solid

Skin : The Model Skin # used by this goal item. This obviously only works if multiple skins are
available.

mdl: The mdl used by this Goal. The path to the models in fortress is usually:

progs/model_name
If no model is specified for the item, it will be invisible. This is not a good idea for an item.

netname: variable used to assign a distinctive name to an entity. ENTed uses this value.

goal_result : Determines what results are applied to APA. Bitfields:
1 : Goal is removed after activation.
2 : Goals activated by this one apply their results to the AP.
4 : Display scores and end the level.
8 : Activated goals will not apply their results to the APA
16 : Disable/Stop the spy’s undercover mask.
32 : This forces APA to simply respawn. The player doesn’t die… just respawns.
4096 : If this bit is set, any player carrying this item can drop it using the “dropitems” command.

pausetime : Item is removed if not touched for this time after being dropped by a dying player. Also, see bit 32 in “goal_activation” above.

N.B. This is not used if bit 128 in “goal_activation” is not enabled.

message : This message is centerprinted to the APs screen.

goal_no : Unique ID number of this goal.

goal_effects : Determines what players are affected. Bitfields.
1 : AP is affected. (default)
2 : Everyone on the AP’s team is affected.
4 : Everyone not on the AP’s team is affected.
8 : Everyone except the AP is affected.
16 : Radius effect (see “t_length”) does not go through walls.

items : Specifies which console icon to light up when this Item is carried. Bitfield.
131072 : Silver Key
262144 : Gold Key

origin : this line holds the exact coordinates of the entity within the map. don’t fiddle with this.

 


2.7 info_tfgoal_timer

I have never used this entity, nor does the description of this entity interest me. It cannot be used to activate another goal. It could be used although, to affect all players. I did not use this entity in the EXAMPLE1.MAP, if you wish to have more info on this TF entity, you can consult the TFORTMAP.TXT file, which holds a very detailed description.


3.1 The Example Map.

A great deal of information has been given concerning the use of TF entities in the example map. Some people have probably gotten answers to their questions concerning the creation of a TF map. I would say the majority however, are still confused, especially when it comes to BITFIELDS to select the various options we would like to activate in our entity variables.

See Appendix 1, for information on Bitfields.

Once we understand the process involved in turning options on/off in our entities, we can start to see the possibilities available to us. There are a great deal of advanced topics such as controlling Quake entities through a TF goal, creating complex scoring systems in which goal activation must be done in order etc…

I suggest at this point, that you load the EXAMPLE1.MAP file in ENTed to follow the text, while analysing the various options and menus that ENTed makes available to you.

The goal of this Tutorial is to explain the simple capture the flag (CTF) scenario, which is ever so popular with players and budding mapmakers. We have seen the 5 TF entities available to us, along with the entity data from the actual EXAMPLE1.MAP file. But now we’ll look at it all in a different, less technical light.


3.2 What we need:

In order to create a Team Fortress map, we must follow a certain formula that EVERY TF map follows. There are REQUIRED steps we must take, in order to make a TF map work.

  • info_tfdetect: We must have an info_tfdetect entity
    somewhere in our map, that will give
    the TF patch the proper startup
    information.

In the EXAMPLE1.MAP, I positionned the entity right
under the right side ledge, behind the ladder.

  • 2- info_player_teamspawn: Every team must have at least
    one spawn point to itself. It is a good
    idea to have at least 1 spawn point for
    every 4 players in each team.

In a 2 team, 32 player map, we should estimate 16 players in each team, therefore 4 spawn points for each team.

There is only one spawnpoint for each team in the example map.

The above is ALL that is really required to create a valid Team Fortress map. All your classes would work and so would your teams. But the only way to score points in such a map, would be through frags. I have never seen such a TF map, but that is probably due to the fact that Deathmatch is more
suitable for frag only play.


3.3 Scoring System:

The game of Capture The Flag has always been popular. It also happens to be among the easiest scoring systems to implement in a TF map. I noticed that clone after clone of 2fort4, hardly anyone decided to spice it up. That is more of a philosophical question than anything else.

When planning for your TF map, most of the time, you will know in advance, what sort of scoring system you wish to have. Planning is always a big bonus in any project. You should take a look at the various goal options are available to you, and decide whether you will want to shift from the usual CTF.

In my first map, The Outpost, I had decided to give the flag capturing player an extra frag over his teammates. This will encourage certain lower player classes to do their stuff. Such as scouts, who don’t stand much of a change in a firefight, but who could really use that extra frag per capture, in order to distinguish themselves in their team ranks.

In the EXAMPLE1.MAP, there was no frags given to any teams, because for the example, I chose to make the goal work with either team, therefore the frags were only given to the APA.

In order to make a CTF scoring system work, we need the following for EACH team:

a flag : item_tfgoal
a flag capture point: info_tfgoal

NOTE: you do not capture your own flag in your own base, therefore the flag cannot be taken by your own team, and the flag capture point will work only with enemy flags.

In order to better understand the way these entities work, you should print out the entities contained within the EXAMPLE1.MAP and then load the map in ENTed for experimenting. As you turn options on/off, add or remove.. keep an eye on the FIELDS Tab and see what has changed or disapeared. You can always type the entities over again if you accidently deleted something you shouldn’t have.


3.4 The Crates:

I noticed in MANY maps, that the author created stacks of crates, by copying one crate over and over. That is one way of doing it. But a beginning mapmaker should always try to avoid taking the easy way out of things. That will only cause problems later in the mapmaking process. Many maps have a great deal of potential, but are so badly structured that they exhibit some very harsh problems such as grey-outs, which occur when the Quake engine cannot fully draw the scene before it. Some maps are really well made, but are filled with so much needless detail, that they slow down to a crawl.

The crates in the EXAMPLE1.MAP look like stacks of individual crates, but in reality, are made out of larger brushes with the textures aligned in order to give the illusion of seperate crates. Load up the .MAP in your favorite editor in order to see what I mean more clearly.

Sure, this is a very innane detail. But there are a great deal of instances in which a good deal of effectiveness can be gained by using a touch of foresight. You should also avoid needless
use/abuse of the carving tool. Try to achieve the same visual effect by manually creating the brush composition you need.


3.5 The Ladder:

While working on my map, The Outpost, I had really started getting annoyed of using ramps for everything. Especially when I first started working on the outside bunkers. I had initially
planned on using a ramp, but the amount of room you need to make a proper ramp is just crazy. In tight spaces, when you need to get some height, they are useless. I eventually used lifts to solve
my problem, but maybe in a future version of The Outpost, if there is any demand for one. I will replace the lifts with ladders.

When I first played on BAM4, by Midori, I just flipped out over those nifty ladders he created! I was lucky enough to get a message from Midori with the secret behind this technique.

You will have to load the EXAMPLE1.MAP in your favorite editor and zoom in nice and close to the ladder. You will notice that the front of the ladder texture is made of solid blocks with
a height of 16 (17 is the highest a player can step without jumping). The blocks have a 2 unit wide step.

Once you have the proper brush arrangement. All you need to do is apply the ‘clip’ texture to the brushes. The ‘clip’ texture is transparent and can be shot through, but the player cannot MOVE through it. Therefore when you step towards the invisible steps, you actually climb the invisible steps and not the decorative rungs of the ladder.


4.0 Conclusion

I have given you all the information you need in order to create a basic TF map with CTF scoring system. I am sure I forgot to mention something or that a specific section could be made more
clear. I would be glad to answer your questions and add insight or even the answers to frequently asked questions. But in order to do this, I need feedback. So feel free to contact me.

grimm [502]
March 10th 1998.


New Since v1.0

-in the item_tfgoal section, fixed some entity information on:

goal_activation (added all the missing bitfield info)
goal_result – (added the missing bitfield info)
items – (removed the lights for quad, invinsibility etc..)

17 is the highest a player can step without jumping!
-In ENTed you should keep an eye on the FIELDS tab and NOT the
‘details’ tab.

Added the two new Appendixes on Bitfields & Decimal/Binary Conversion.


Appendix 1. BITFIELDS - grimm [502]

Why do we need to understand what a bitfield is? Well in TF, the entities make tremendous use of bitfields in order to turn entity options ON/OFF. Bitfields are used in the Binary numbering system, to designate each bit.

{
“classname” “item_tfgoal”
“goal_activation” “693”
}

This is an example of bitfields in use, taken from our flag entity from the EXAMPLE1.MAP. Now how do we figure out what options are currently set, from the goal_activation field? Well we can probably just wing it, by adding up various values, you see, every bitfield in the entity info, is given a value:

1 : Carrying Player glows.
2 : Carrying Player moves at half speed.
4 : Item is dropped when a player with it dies.
8 : Item is returned when dropped.
16 : Item is returned when removed from players by a Goal
32 : Item is returned due to “pausetime” (see below)
64 : Only activated (picked-up) if AP fails Criteria.
128 : Enable “pausetime” removing.
256 : Players keep this item when they die.
512 : If this Item isn’t being carried, it glowsdimly.
1024: Don’t remove the results of this Item when it’s removed from a player.
2048 : If this bit is set, the GoalItem drops to the ground when it first spawns.
8192 : If this bit is set, the GoalItem is Solid

693= 512+128+32+16+4+1

512: If this item isn’t being carried, it glows dimly.

128: Enable “pausetime” removing

32: Item is returned due to “pausetime” (see above)

16 : Item is returned when removed from players by a Goal

4 : Item is dropped when a player with it dies.

1 : Carrying Player glows.

But this method is long and tedious. The real way to find out what options are turned ON or OFF, we should simply convert our number from decimal (693) to binary (1010110101). We could then easily and effectively determine what options we have on or off. But many of you probably do not know much about BINARY, or how to convert from Decimal to Binary, or vice-versa. The following is something Jon Zorn [502] put together for this tutorial on just such information. Enjoy.


Appendix 2. Decimal/Binary conversion -Jon Zorn [502]

By using simple division and keeping track of the remainder we can figure out what the binary equivalent is. Here’s how it works, take the number you want to convert to binary and divide by 2, this leaves you with a quotient and a remainder, so mark what the remainder is on the side. Now take the quotient and divide by 2, mark what the remainder is and divide quotient by 2. We keep
doing this until the quotient is zero, once that happens we have our binary number in the the list of remainders, only problem is that its listed backwards, so we have to read it backwards.

Here’s an example, let’s take 502:

502 / 2 = 251 with remainder 0
251 / 2 = 125 with remainder 1
125 / 2 = 62 with remainder  1
 62 / 2 = 31 with remainder  0
 31 / 2 = 15 with remainder  1
 15 / 2 = 7 with remainder   1
  7 / 2 = 3 with remainder   1
  3 / 2 = 1 with remainder   1
  1 / 2 = 0 with remainder   1
  0 / 2 oops quotient is zero so we stop

The binary number is in the remainder but remember its backwards so we read it as 111110110 and NOT as 011011111(this is a totally different number!).
Another 2 examples:

 For 138:                For 340:

138 / 2 = 69    R:0      340 / 2 = 170    R:0
 69 / 2 = 34    R:1      170 / 2 = 85     R:0
 34 / 2 = 17    R:0       85 / 2 = 42     R:1
 17 / 2 = 8     R:1       42 / 2 = 21     R:0
  8 / 2 = 4     R:0       21 / 2 = 10     R:1
  4 / 2 = 2     R:0       10 / 2 = 5      R:0
  2 / 2 = 1     R:0        5 / 2 = 2      R:1
  1 / 2 = 0     R:1        2 / 2 = 1      R:0
                           1 / 2 = 0      R:1
 

we have 10001010 for 138   and 101010100 for 340

To convert binary to decimal it’s a little more annoying. Each digit from right to left is worth 2 to the power of something, and that something depends on the digits position. Starting from right to left the number to raise 2 to the power of goes up 1 at a time starting from zero example:

The powers to raise 2 to: 7 6 5 4 3 2 1 0

Binary number : 1 0 0 0 1 0 1 1
                ³ ³ ³ ³ ³ ³ ³ --2 to the power of 0 = 1
                ³ ³ ³ ³ ³ ³ ----2 to the power of 1 = 2
                ³ ³ ³ ³ ³ ------2 to the power of 2 = 4
                ³ ³ ³ ³ --------2 to the power of 3 = 8
                ³ ³ ³ ----------2 to the power of 4 = 16
                ³ ³ ------------2 to the power of 5 = 32
                ³ --------------2 to the power of 6 = 64
                ----------------2 to the power of 7 = 128

What does all this mean? Well now you just have to make a list as follows: for every 1 in the binary number take the position and raise 2 to the power of that position and add it to the list, ignore the zeros since they’re not too important in binary. Once you’ve gone through the entire binary number, just add up all the numbers in the list and you got the decimal equivalent, here’s an example:

Lets take binary number 10001010:
Now for each 1 digit in the number we raise 2 to the power of that position:
These are all the powers: 7 6 5 4 3 2 1 0

1 0 0 0 1 0 1 0
|       |   |
|       |    ----2 to the power of 1 = 2
|        --------2 to the power of 3 = 8
 ----------------2 to the power of 7 = 128

And Add up the list: 2+8+128 = 138

Remember you raise 2 to the power of the position and the position starts from right to left and starts at zero not 1! Another example with a larger number, 110001001001 (I use the ^ symbol to
denote “to the power of”).

These are the powers: 11 10 9 8 7 6 5 4 3 2 1 0

Binary number: 1 1 0 0 0 1 0 0 1 0 0 1
               | |       |     |     |
               | |       |     |      --2^0 = 1
               | |       |      --------2^3 = 8 
               | |        --------------2^6 = 64
               |  ----------------------2^10 = 1024
                ------------------------2^11 = 2048

Add the list up: 1+8+64+1024+2048 = 3145

Thats all! –Jon Zorn [502]


This site and it’s content is copyright F.C.O. enr. 1998.
All original art and graphics are watermarked for authentication purposes. The content submitted by contributors is copyright by the respectful owner.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.