Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need algorithm
Message
From
07/07/2011 10:39:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Games
Category:
Trivia
Title:
Miscellaneous
Thread ID:
01517506
Message ID:
01517587
Views:
31
>>>What I don't understand is how do you go from bit to number that will be stored in the field. For example, say only the 1st option box is selected. Does it mean that the value of 1 is set to the field? And if Option 1 and 2 are selected, the value of 3 is set to the field? And in case of all three options boxes, the value is 7?
>>
>>The options have numerical values 1, 2, and 4 assigned (for more than 3 options, use additional powers of 2: 8, 16, etc.). If one bit is set, add the values of the individual bits, e.g. 101(binary) = 4 + 1. To get the combined value:
>>
>>
>>CombinedValue = iif(CheckBox0.Value, 1, 0) + iif(CheckBox1.Value, 2, 0) + iif(CheckBox2.Value, 4, 0)
>>* (Assuming you changed the checkbox to a logical type. Otherwise, use iif(CheckBox.Value = 1...))
>>
>
>I get it now. Thank you very much!

A bit more theory: the binary system is quite similar to the decimal system we use on a daily basis - it is based on place-value. The only difference is that the decimal system uses base ten - meaning that each position is worth 10 times the position to its right (therefore it requires ten different digits). In binary, each position is worth twice the position to its right, thus only two digits are required.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform