I want to convert 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
to its decimal equivalent and no I am not wanting to display
5092 + e to the something , I am trying to figure out how I can actually display to the user this:
509258994083621521567111422102344540262867100557355601717974933926024279115076881119969280 . Before anyone says it,
no I can not use the

BigInteger

datatype to help. Any ideas of how I can do this? I heard that you can actually like store
0-9 in binary or something and do that when you take input as a vector of strings or something? I was kind of confused about the process. I guess i would store as strings some where
001, 010, 100.. somewhere in code and somehow reference that? Idk any help would be GREATLY appreciated. I'm very lost on what to do.

long
–9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 is 19 digits.
Signed 64-bit integer
System.Int64 ... .NET Framework type

However, even 2^149 is a huge integer =~ 7.1362385e+44,
i.e. 713623850000000000000000000000000000000000000

sham25, the .NET Framework supports standard arithmetic; even System.Decimal, a 128-bit datatype, supports < 30 significant digits:

decimal
(-7.9 x 1028 to 7.9 x 1028) / (100 to 28)
28-29 significant digits
System.Decimal ... .NET Framework type

sham25, the general answer to your question is that your large numbers need to be represented as
custom objects supported by custom code ... written by you or a third party.

THE BIG QUESTION is WHY would you want to do this? Please explain.

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

It's a homework problem for school. I think I need to use the Double Dabble Algorithm. Unfortunately, I can't find any examples of source code for the Double Dabble Algorithm anywhere - and I'm trying as hard as possible
to not re-invent the wheel here lol.

it would have been best for you to have been honest with your peers here at forums.asp.net from the beginning about this being a homework problem.

FWIW, i am a former community college computer science instructor who has been writing computer programs since 1967 — if my students had someone else do their homework, i'd give them zero marks — learning happens by doing and researching — your peers here
at forums.asp.net can help you best by guiding you, not by doing your homework for you.

help us help you!

(a) how did your teacher actually specify the problem?

i've answered the question you've asked ... in the c# world, Decimal means System.Decimal which is a c# data type that is not capable of holding the result of the conversion.

(c) at what level of school has this question been presented to you? imho, it requires a very good background to solve this because it's non-trivial.

obviously it's solvable because Taylor Hornby has done it here: https://defuse.ca/big-number-calculator.htm — however, you would need to store
your intermediate and final results in a well designed classinstance and display the results as a System.String — this means you'd also need a custom .ToString method.

Hint: search via Google or your favourite search engine for algorithms for displaying large powers of two as text — if you get lucky, you will find techniques that you can use to solve you problem.

(d) please restate your homework assignment with clarity — if necessary, get your teacher to do the same for you first.

(e) be honest with your teacher that you are seeking external help.

BTW, i was a very mean computer science instructor — if a student presented an answer but could not explain it, it was fair to assume that someone else provided that answer and zero marks were likely to be given.

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

Also the solution will depend on what you know (and we don't know what you know). Your teacher may not expect some kind of super advanced solution but rather than you put in practice what you just learned for example maybe an array based solution if you
just learned about arrays.

Anyway even when not homework I prefer to explain what to do or how to solve something rather than providing ready to paste code. IMO you learn much more by coding yourself based on some help rather by just copying and pasting code and this is valid even
if not at school anymore.

Think of types like Decimal, Int64, et cetera as being like buckets that can only hold so much; if you have more than one bucket can hold, you need more buckets:
[ffffffffffffffff] [ffffffffffffffff]

Just like adding real columns of numbers, you need to be able to carry into the next column if necessary:
[ffffffffffffffff] [ffffffffffffffff] is

sham250, your peers at forums.asp.net are still waiting to hear from you.

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

Secondly, I wasn't trying to be "dishonest". I've already failed this assignment. Even know I got the correct answers it wasn't the "method my teacher wanted" so I received a failing grade. I am now trying understand how the correct
way to do this problem is. I already understand how to do Binary, I already understand how to convert Binary to Decimal. These are all trivial problems to me. What I am stuck with is using
this extremely vague pseudo code that has been prevented to me by my teacher (check out pseudo code via the stack overflow link I posted above ^) to try to attempt to convert this massive number into decimal. Hexadecimal is great
but really is irrelevant for what I am trying to do. I keep getting the example "We know how to add 9382 + 4567.. blah blah" that's great I know how to add huge numbers by putting them in strings and storing carries somewhere else by adding
each column at a time, but is this assignment really implying that I multiply out numbers past 2^64 using a string type method of storing carries to their respective columns? Also, if that is the case - I just do not
understand how to implement this. Anyways, I believe the by2indec function (that is available via stack overflowlink I've posted above) is written correctly, yet I am still getting weird numbers. Perhaps it's incorrect. Any advice you can give or any direction you can point me in would be GREAT. I want to reiterate that this assignment has already
been past due and I received a FAILING GRADE. I am trying to understand how to do it for my own personal benefit. Thanks again for your time gerry and for taking time to listen and to attempt to solve my problem. I have spent almost a week trying to figure
out how to implement this pseudo code I've been given but I'm unsure of what the by2indec function should actually be doing. People have been telling me to use the Double Dabble Algorithm to solve this, I
even attempted to write code for that to no avail. There are no examples of it in C# either. Thank you for your time Gerry, at this point with your experience and knowledge ANY direction you point me in will be the correct one.

First, i respect you for your tenacity ... i suspect that many students who fail an assignment would want to move on and forget all about.

Second, when a teacher demands a specific method from his/her students, it's often for the benefit of the teacher (it's easier to mark one solution 30 times than it is to mark 30 unique solutions); such pedagogy stifles creativity.

There is a story about seven year old mathematician Gauss creating the formula n(n+1)/2 when his elementary school teacher assigned "busy work" to the class by asking the students to sum the numbers 1 to 100. http://www-history.mcs.st-and.ac.uk/Biographies/Gauss.html

function ItBin2dec(v)
Input: An n-bit integer v ≥ 0 (binary digits)
Output: The vector w of decimal digits of v
w = []
for i =size(v) − 1 downto 0:
w =By2inDec(w)
if v is odd:
if w = []: w = [1]
else: w[0] = w[0] + 1
return w

function ItBin2dec(v)

(a) the It part of the function name tells me nothing, so i'm going to have to ignore the first 2 letters.

(b) Bin2dec appears to be a lazy way of writing binary to decimal and implies a converision from base 2 to base 10.

(c) (v) suggests that the function is being passed a binary number.

FWIW, an algorithm is likely to be affected by data type; since your teacher wants a arbitrary number of binary digits (n-bit) and since today's hardware based native number formats that can be directly handled by the processor are not of
arbitrary length, a better statement would have been:

Input: an arbitrary string of length n, n > 0, consisting only of the characters '1' and '0' where the rightmost character represents base 2 position 2^0 and the leftmost character represents the base 2 position 2^(n-1); only unsigned binary numbers are represented; the base 10 value of any non-zero position is its power of 2 value.

(f) "The algorithm By2inDec(z) takes as input the vector of
decimal digits of an integer z and returns the vector of decimal digits of
2z."
Again your teacher is abusing terms like "vector"and "decimal digits".

it appears that your teacher is trying to say "for any integer z, return z+z (i.e. 2 times z)

(g) i'm going to attempt to interpret the following line by line:

w = []
for i =size(v) − 1 downto 0:
w =By2inDec(w)
if v is odd:
if w = []: w = [1]
else: w[0] = w[0] + 1

w = []
// define w as a _____

for i =size(v) − 1 downto 0:
// interate over v, using as an index the length of v less 1
// counting down inclusive of the zero position.

this introduces a problem ... experience tells us that i is likely an index, however i is never used in the rest of the enclosed code:

w =By2inDec(w)
if v is odd:
if w = []: w = [1]
else: w[0] = w[0] + 1

the above has a second problem: w appears to be unassigned on the first iteration:

w = []
-------
w =By2inDec(w) // ergo w =By2inDec([])

if v is odd:
// which 'v'? v[i] ???

i'm going to ignore these two lines:

if w = []: w = [1]
else: w[0] = w[0] + 1

--------------------------------------------------------
Moving on.

Here's my attempt at a more reasonable pseudo-code:

public static String ArbitraryBinaryConvertToDecimal(String onesAndZeros)
// c#: the leftmost character is index value zero
// c#: the rightmost character is index value (string length minus 1)
the input string must contain only ones and zeros and
is of an arbitrary length > 0;
else throw an exception.
the input string represents an unsigned binary number.
return value: the base 10 equivalent of the input string.
String currentPowerOf2 = "1"; // zero
String totalDecimalValue = String.Empty;
starting with the rightmost character,
moving left until the index zero character has been processed:
{
if onesAndZeros[index] = '1'
{
totalDecimalValue = AddTwoBase10Strings(totalDecimalValue, currentPowerOf2)
}
currentPowerOf2 = AddBase10StringToItself(currentPowerOf2)
decrementIndex
}

public static String AddTwoBase10Strings(String firstString, String SecondString)

public static String AddBase10StringToItself(String StringToBeDoubled)

sham25, pseudo-code generally (for English speaking persons) should be more like English and less like code.

PLEASE if you are able, provide your peers here at forums.asp.net with the exact problem statement as given by your teacher.

B-) Gerry Lowry, Chief Training Architect, Paradigm Mentors Learning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it

None

0 Points

3 Posts

## Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 12:03 AM|sham25|LINK

I want to convert

10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000to its decimal equivalent and no I amnotwanting to display5092 + e to the something, I am trying to figure out how I can actually display to the user this:509258994083621521567111422102344540262867100557355601717974933926024279115076881119969280. Before anyone says it,noIcan notuse thedatatypeto help. Any ideas of how I can do this? I heard that you can actually like store0-9in binary or something and do that when you take input as a vector of strings or something? I was kind of confused about the process. I guess i would store as strings some where001, 010, 100..somewhere in code and somehow reference that? Idk any help would be GREATLY appreciated. I'm very lost on what to do.Star

14297 Points

5797 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 02:49 AM|gerrylowry|LINK

@sham25 welcome to forums.asp.net

Let's look a your 90 digit integer:

Your binary number is 299 binary characters:

Your binary number expressed as a decimal integer would be the sum of:

c# lets you use the

longvalue type: https://msdn.microsoft.com/en-us/library/ctetwysk.aspx "long(C# Reference)"However, even 2^149 is a huge integer =~ 7.1362385e+44,

i.e. 713623850000000000000000000000000000000000000

sham25, the .NET Framework supports standard arithmetic; even System.Decimal, a 128-bit datatype, supports < 30 significant digits:

sham25, the general answer to your question is that your large numbers need to be represented as

custom objectssupported bycustom code ...written by you or a third party.THE BIG QUESTION is WHY would you want to do this? Please explain.

References:

https://en.wikipedia.org/wiki/Binary_number

https://en.wikipedia.org/wiki/Scientific_notation

https://msdn.microsoft.com/en-us/library/364x0z75.aspx "

decimal(C# Reference)"https://msdn.microsoft.com/en-us/library/s1ax56ch.aspx "

Value Types(C# Reference)"EDIT:such calculations are possible, but not with the standard .NET Framework.

one example: https://defuse.ca/big-number-calculator.htm

2^149 =

713623846352979940529142984724747568191373312

2^298 =

509258994083621521567111422102344540262867098416484062659035112338595324940834176545849344

END EDIT.EDIT # 2:Taylor Hornby's calculator can also handle expressions like:

2^298 + 2^150 + 2^149 =

509258994083621521567111422102344540262867100557355601717974933926024279115076881119969280

END EDIT # 2.B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do itNone

0 Points

3 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 10:39 AM|sham25|LINK

It's a homework problem for school. I think I need to use the

Double Dabble Algorithm. Unfortunately, I can't find any examples of source code for theDouble Dabble Algorithmanywhere - and I'm trying as hard as possible to not re-invent the wheel here lol.Star

14297 Points

5797 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 02:04 PM|gerrylowry|LINK

@sham25

it would have been best for you to have been honest with your peers here at forums.asp.net from the beginning about this being a homework problem.

FWIW, i am a former community college computer science instructor who has been writing computer programs since 1967 — if my students had someone else do their homework, i'd give them zero marks — learning happens by doing and researching — your peers here at forums.asp.net can help you best by guiding you, not by doing your homework for you.

help us help you!(a) how did your teacher actually specify the problem?

i've

answeredthe question you've asked ... in the c# world,Decimal means System.Decimal which is a c# data type that isnotcapable of holding the result of the conversion.clarityis important — reading this article that i wrotecouldhelp you get a better answer to a better question:Clarity is important, both in question and in answer.

(b) if you post in other forums you should say so ... for example, someone posted this deleted question on stackoverflow:

http://stackoverflow.com/questions/32622345/converting-huge-binary-numbers-to-decimal-in-c-sharp-how

[its author removed it voluntarily]

stackoverflow suggests this currently

unansweredquestion as an alternative:http://stackoverflow.com/questions/960264/convert-really-big-number-from-binary-to-decimal-and-print-it

unfortunately that will not help you because its currently

unanswered.(c) at what level of school has this question been presented to you? imho, it requires a very good background to solve this because it's non-trivial.

obviously it's

because Taylor Hornby has done it here: https://defuse.ca/big-number-calculator.htm — however, you would need to store your intermediate and final results in a well designedsolvableclassinstanceand display the results as a System.String — this means you'd also need acustom.ToStringmethod.Hint: search via Google or your favourite search engine for

algorithms for displaying large powers of two as text— if you get lucky, you will find techniques that you can use to solve you problem.(d) please restate your homework assignment with

clarity— if necessary, get your teacher to do the same for you first.(e) be honest with your teacher that you are seeking external help.

BTW, i was a very mean computer science instructor — if a student presented an answer but could not explain it, it was fair to assume that someone else provided that answer and zero marks were likely to be given.

B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do itAll-Star

43720 Points

15301 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 04:24 PM|PatriceSc|LINK

Also the solution will depend on what you know (and we don't know what you know). Your teacher may not expect some kind of super advanced solution but rather than you put in practice what you just learned for example maybe an array based solution if you just learned about arrays.

Anyway even when not homework I prefer to explain what to do or how to solve something rather than providing ready to paste code. IMO you learn much more by coding yourself based on some help rather by just copying and pasting code and this is valid even if not at school anymore.

Star

14297 Points

5797 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 17, 2015 07:01 PM|gerrylowry|LINK

@sham250

building on what PatriceSc wrote above, if you simply just copy and paste code, you will never be a programmer.

Before translating a solution into code, you need to understand the problem in your own language.

Here are more hints:

for any

binary numberof the general form ...(1|0)(1|0)(1|0)(1|0)...(1|0) you only care about the1's.starting from the

rightmostposition, counting up from zero, the value of any1is2^n, wherenindicates its position.Example, converting from binary to decimal:

00001001 = 2^3 + 2^0 = 2x2x2 + 1 = 8 + 1 = 9 base 10

For smaller numbers than the one that is part of your homework assignment, you can get away with using .NET Framework types.

output:

Your can simply convert each hexadecimal digit into its binary equivalent:

Think of types like Decimal, Int64,

et ceteraas being likebucketsthat can only hold so much; if you have more than one bucket can hold, you need more buckets:[ffffffffffffffff] [ffffffffffffffff]

Just like adding real columns of numbers, you need to be able to carry into the next column if necessary:

[ffffffffffffffff] [ffffffffffffffff] is

sham250, your peers at forums.asp.net are still waiting to hear from you.

B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do itNone

0 Points

3 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 18, 2015 03:02 PM|sham25|LINK

You can check my stack overflow post here first of all: http://stackoverflow.com/questions/32646201/having-trouble-incorporating-algorithm-pseudocode-any-help-would-be-great?noredirect=1#comment53140060_32646201

Secondly, I wasn't trying to be "dishonest". I've already failed this assignment. Even know I got the correct answers it wasn't the "method my teacher wanted" so I received a failing grade. I am now trying understand how the correct way to do this problem is. I already understand how to doBinary, I already understand how to convertBinarytoDecimal. These are alltrivialproblems to me. What I am stuck with is using this extremely vague pseudo code that has been prevented to me by my teacher (to try to attempt to convert this massive number into decimal. Hexadecimal is great but really is irrelevant for what I am trying to do. I keep getting the example "We know how to add 9382 + 4567.. blah blah" that's great I know how to addcheck out pseudo code via the stack overflow link I posted above ^)huge numbersby putting them in strings and storing carries somewhere else by adding each column at a time, but is this assignment really implying that Imultiplyout numbers past2^64using a string type method of storing carries to their respective columns? Also, if that is the case - I justdo notunderstand how to implement this. Anyways, I believe theby2indecfunction (is written correctly, yet I am still getting weird numbers. Perhaps it's incorrect. Any advice you can give or any direction you can point me in would be GREAT. I want to reiterate that this assignment has already been past due and I received a FAILING GRADE. I am trying to understand how to do it for my own personal benefit. Thanks again for your time gerry and for taking time to listen and to attempt to solve my problem. I have spent almost a week trying to figure outthat is available via stack overflowlink I've posted above)howto implement this pseudo code I've been given but I'm unsure of what theby2indecfunction should actually be doing. People have been telling me to use theDouble Dabble Algorithmto solve this, I even attempted to write code for that to no avail. There are no examples of it in C# either. Thank you for your time Gerry, at this point with your experience and knowledgeANYdirection you point me in will be thecorrectone.Star

14297 Points

5797 Posts

## Re: Converting HUGE Binary numbers to Decimal in C# HOW?

Sep 18, 2015 09:06 PM|gerrylowry|LINK

@sham25

First, i respect you for your tenacity ... i suspect that many students who fail an assignment would want to move on and forget all about.

Second, when a teacher demands a specific method from his/her students, it's often for the benefit of the teacher (it's easier to mark one solution 30 times than it is to mark 30 unique solutions); such pedagogy stifles creativity.

There is a story about seven year old mathematician Gauss creating the formula n(n+1)/2 when his elementary school teacher assigned "busy work" to the class by asking the students to sum the numbers 1 to 100. http://www-history.mcs.st-and.ac.uk/Biographies/Gauss.html

TIMTOWTDI

working with what you've presented here http://stackoverflow.com/questions/32646201/having-trouble-incorporating-algorithm-pseudocode-any-help-would-be-great, i'm going to pick it apart (and later try to handle it properly).

function

ItBin2dec(v)(a) the It part of the function name tells me nothing, so i'm going to have to ignore the first 2 letters.

(b) Bin2dec appears to be a lazy way of writing

binary to decimaland implies aconverisionfrom base 2 to base 10.(c) (v) suggests that the function is being passed a

binary number.(d) "Input: An n-bit

integerv ≥ 0 (binary digits)" ... this imho is a sloppy description of the input:https://en.wikipedia.org/wiki/Integer

https://en.wikipedia.org/wiki/Integer_(computer_science)

FWIW, an algorithm is likely to be affected by data type; since your teacher wants a

arbitrary number of binary digits(n-bit) and since today's hardware based native number formats that can be directly handled by the processor are not ofarbitrarylength, a better statement would have been:(e) "Output: The vector w of decimal digits of v" ... this imho is a sloppy description of the output.

http://www.oxforddictionaries.com/definition/english/vector

(f) "The algorithmand "

By2inDec(z)takes as input theof anvectorofdecimal digitsinteger zand returns the vector of decimal digits of2z."Again your teacher is abusing terms like "

vector"decimal digits".it appears that your teacher is trying to say "for any integer z, return z+z (i.e. 2 times z)

(g) i'm going to attempt to interpret the following line by line:

this introduces a problem ... experience tells us that i is likely an index, however i is never used in the rest of the enclosed code:

the above has a second problem: w appears to be unassigned on the first iteration:

i'm going to ignore these two lines:

--------------------------------------------------------

Moving on.

sham25 ... i do not see the relevance of this: https://en.wikipedia.org/wiki/Double_dabble

your example http://stackoverflow.com/questions/32646201/having-trouble-incorporating-algorithm-pseudocode-any-help-would-be-great does not even mention it.

Here's my attempt at a more reasonable pseudo-code:

sham25,

pseudo-codegenerally(for English speaking persons) should bemore like Englishandless like code.seehttps://en.wikipedia.org/wiki/PseudocodePLEASEif you are able, provide your peers here at forums.asp.net with theexactproblem statement as given by your teacher.B-) Gerry Lowry, Chief Training Architect,Paradigm MentorsLearning never ends... +1 705-999-9195 wasaga beach, ontario canada TIMTOWTDI =.there is more than one way to do it