Click here to Skip to main content
15,900,973 members
Home / Discussions / C#
   

C#

 
GeneralRe: just cant get this code to produce correct value Pin
Luc Pattyn16-Sep-10 10:50
sitebuilderLuc Pattyn16-Sep-10 10:50 
AnswerRe: just cant get this code to produce correct value Pin
T M Gray16-Sep-10 10:40
T M Gray16-Sep-10 10:40 
GeneralRe: just cant get this code to produce correct value Pin
stephen.darling16-Sep-10 10:58
stephen.darling16-Sep-10 10:58 
GeneralRe: just cant get this code to produce correct value Pin
Richard MacCutchan16-Sep-10 22:44
mveRichard MacCutchan16-Sep-10 22:44 
GeneralRe: just cant get this code to produce correct value Pin
T M Gray17-Sep-10 4:08
T M Gray17-Sep-10 4:08 
GeneralRe: just cant get this code to produce correct value Pin
Richard MacCutchan17-Sep-10 6:04
mveRichard MacCutchan17-Sep-10 6:04 
GeneralRe: just cant get this code to produce correct value Pin
AspDotNetDev16-Sep-10 12:04
protectorAspDotNetDev16-Sep-10 12:04 
AnswerRe: just cant get this code to produce correct value Pin
AspDotNetDev16-Sep-10 12:47
protectorAspDotNetDev16-Sep-10 12:47 
I don't feel like reviewing that algorithm. Below is some pseudo-code for a new algorithm. Basically, you get the value of each base-10 digit, convert it to binary, then sum all those values (so, 123 would be 100 + 20 + 3, which in binary would be 1100100 + 10100 + 11, which would equate to 1111011).
Create a multiplier array. Set it to a value of 1 (i.e., a single element with the value set to 1).
Create a result array. Set it to a value of 0 (i.e., a single element with the value set to 0).
Create a secondary array. It's value will be set later.
Loop from the last char to the first char.
	Create a product array by multiplying the char value by the multiplier array (note: 5x = x + x + x + x + x).
		Initialize product array to the size of the multiplier array plus 1 (set each element to a value of 0).
		Loop from 1 to char value.
			Assign the product array the result of binary adding the product array and the multiplier array.
	Binary add the product array to the value array and assign it to the value array, adding a head byte if necessary.
	Multiply the multiplier array by 10 (note: 10x = x+x+x+x+x+x+x+x+x+x) (optimization: 10x = 8x + 2x).
		Copy the multiplier array to the secondary array.
		Multiply secondary array by 2.
			Prefix a head byte to the secondary array.
			Shift all the bits in the secondary array to the left by 1 bit (discard the first bit).
		Multiply multiplier array by 8.
			Prefix a head byte to the multiplier array.
			Shift all the bits in the multiplier array to the left by 3 bits (discard the first 3 bits).
		Binary add the secondary array and the multiplier array and assign the result to the multiplier array.
		If the first byte in the multiplier is 0, remove it (this isn't necessary, but will reduce memory used).
Repeat loop until first char is reached and processed.
Remove any bytes from the head of the value array that are 0 (they are meaningless, just as the zeroes on 00000123 are meaningless).

When I say "array", I mean an array of unsigned bytes. You can find instructions online for how to add two binary values (note: an unsigned byte is essentially 8 binary values). This is not an efficient way to perform the conversion, but it seems like an intuitive one.

QuestionDatetimepicker: manual input Pin
mSh198516-Sep-10 3:36
mSh198516-Sep-10 3:36 
AnswerRe: Datetimepicker: manual input Pin
Łukasz Nowakowski16-Sep-10 4:02
Łukasz Nowakowski16-Sep-10 4:02 
AnswerRe: Datetimepicker: manual input Pin
Mycroft Holmes16-Sep-10 16:04
professionalMycroft Holmes16-Sep-10 16:04 
GeneralRe: Datetimepicker: manual input Pin
mSh198516-Sep-10 20:17
mSh198516-Sep-10 20:17 
AnswerRe: Datetimepicker: manual input Pin
V.16-Sep-10 20:09
professionalV.16-Sep-10 20:09 
GeneralRe: Datetimepicker: manual input Pin
mSh198516-Sep-10 20:18
mSh198516-Sep-10 20:18 
Questionhow to convert a column in gridview to combobox after binding?? Pin
leeoze16-Sep-10 3:26
leeoze16-Sep-10 3:26 
Answerfound the answer :) Pin
leeoze16-Sep-10 3:43
leeoze16-Sep-10 3:43 
QuestionDatagridview returns wrong rownumber Pin
RobScripta16-Sep-10 3:09
professionalRobScripta16-Sep-10 3:09 
AnswerRe: Datagridview returns wrong rownumber Pin
PIEBALDconsult16-Sep-10 3:15
mvePIEBALDconsult16-Sep-10 3:15 
GeneralRe: Datagridview returns wrong rownumber Pin
RobScripta16-Sep-10 3:23
professionalRobScripta16-Sep-10 3:23 
AnswerRe: Datagridview returns wrong rownumber Pin
RobScripta16-Sep-10 4:10
professionalRobScripta16-Sep-10 4:10 
AnswerProblem solved Pin
RobScripta16-Sep-10 4:29
professionalRobScripta16-Sep-10 4:29 
QuestionC# Pin
arindam201016-Sep-10 1:23
arindam201016-Sep-10 1:23 
AnswerRe: C# Pin
OriginalGriff16-Sep-10 1:54
mveOriginalGriff16-Sep-10 1:54 
GeneralMessage Removed Pin
16-Sep-10 2:08
arindam201016-Sep-10 2:08 
GeneralRe: C# Pin
Not Active16-Sep-10 2:17
mentorNot Active16-Sep-10 2:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.