Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Why this is running in infinite loop?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Please anybody help me, why this is running in infinite loop?


Thanks in advance
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think: what is the range of a byte's values? What happens when a byte gets to its maximum value and you add one to it?
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ali,

Know this point helps you:


The MSB position used for sign.
MSB 0 - implies positive number.
MSB 1 - implies negetive number(which will be in 2's complement notation)

[Note: 2'compl( positive number) --> its negetive representation.
-5 = 2's compl(5) ---> 1's complement( make 1 as 0 and 0 as 1) + 1
1111 1011(1 byte)]

In our case MSB is 1. that means it understands negetive number(in 2'comp)

1. 1's compl( 2's compl - 1 ) ---> magnitude of negetive number
2. attaches - to magnitude.( Uses Some falgs do this).



Know once helps all the way.
[ April 20, 2007: Message edited by: Srinivasan thoyyeti ]
 
m ali
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Srinivasan, I got it.
 
m ali
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Srinivasan & Barry, I got it.
 
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic