|
![]() |
If you’ve learned about binary numbers and how to convert from decimal
to binary and the reverse, try writing programs to do those conversions with
unlimited length numbers (but you can assume the numbers are small
enough to be stored in a standard C++ int).
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Okay i got it.Campbell Ritchie wrote:I would suggest that your // comments are too long, and they make the lines difficult to read and I suggest they should be /* comments */ instead.
Actually i am not sure about it in C++.but since i am coding in java i made a convention to deall with java int(32 bits).Campbell Ritchie wrote:How many bits does a C++ int occupy? Are you sure it is always 32?
That is the most awkward thing which comes to my mind when,after writing my code,i go through it.actually they seems like a utility method for my class(so i made them static) but what would you advice should i place them in another utility class.Campbell Ritchie wrote:Why have you got so many static methods?
okay i would use a space.actually i realize that is a bad name,i will change it.i want this method to add leading 0's in order to complete the 32 bit length(that's why i had used it,though i will make it a constant).can you advice some better name.Campbell Ritchie wrote:Main method: please put a space after the ellipsis operator.
In the ensure length method why are you appending 0s to the StringBuilder?
it will flip the argument bit.please look at this method:Campbell Ritchie wrote:What does the flip bit method do? Do you need it?
Okay i got it.it's a bug i will correct it.Campbell Ritchie wrote:If you have one class which does the conversions, what is going to happen if you do this?I think there is a design error in your class. Can you see what I am worried about?
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
I don't get your point.java uses a IEEE 754 standard to represent floats but still there the leftmost bit is the sign bit which,In my opinion,does only carry the sign information.have i missed something? please let me know if i have.Campbell wrote:...Remember the leftmost bit is not a sign bit the way the leftmost bit in a floating‑point number is a sign bit. It represents a value. Also, what do you understand by unsigned right‑shift? ...
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
But that is what I said. In a floating‑point number the leftmost bit represents the sign and nothing else. But in an integer type the leftmost bit has a value (in two's complement in 32 bit, that value is −2³¹praveen kumaar wrote:. . . .java uses a IEEE 754 standard to represent floats but still there the leftmost bit is the sign bit . . .
No, it shifts the bits in i by the rightmost 5 bits in j. It is not the same as integer division if the left operand is negative.
unsigned right shift operator(i >>> j) shifts the bits of i by the value(represented by the 5 least significant bits in i for int and by 6 least significant bits for the long).and the unfilled bits were replaced by 0's.
Kind regards,
Praveen.
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
All things are lawful, but not all things are profitable.
Knute Snortum wrote:I think this would be better:
Try to enjoy your work while doing it,it will Automatically convert in Hard Work...
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
|