Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Part 2 here. here.

Part 2 here.

Part 2 here.

Added link to new question (continuing this one)
Source Link
Tim
  • 115
  • 1
  • 6

Part 2 here.

Part 2 here.

fixed typo
Source Link
Tim
  • 115
  • 1
  • 6
BitStream bs = new BitStream();
int min1 = -1000, max1 = 1000, num1 = 287;
float min2 = 0f, max2 = 50f, num2 = 16.78634f;
double min3 = double.MinValue, max3 = double.MaxValue, num3 = 9845216.1916526;
byte fltPrec = 2;
byte dblPrec = 0;
bs.Write( num1, min1, max1 ); // 12 bits (11 bits for 1000 plus 1 bit for negative sign)
bs.Write( num2, min2, max2, fltPrec ); // converts to 1679 int, 14 bits (maximum converted to int is 5000)
bs.Write( num3, min3, max3, dblPrec ); // precision is ignored here as min/max are too high to try to convert to an integer, so the value is stored using all 64 bits of the double
bs.Write( true ); // 1 bit
int num4;
float num5;
double num6;
bool checker;
bs.Read( out num4, min1, max1 ); // num3num4 = 287
bs.Read( out num5, min2, max2, fltPrec ); // num4num5 = 16.79, there is some loss of precision here
bs.Read( out num6, min3, max3, dblPrec ); // num6 = 9845216.1916526, no loss of precision
bs.Read( out checker ); // checker = true
int newNum;
bs.Read( out newNum, -100, 100 ); // newNum = 0 as there are no bits left in the BitStream
BitStream bs = new BitStream();
int min1 = -1000, max1 = 1000, num1 = 287;
float min2 = 0f, max2 = 50f, num2 = 16.78634f;
double min3 = double.MinValue, max3 = double.MaxValue, num3 = 9845216.1916526;
byte fltPrec = 2;
byte dblPrec = 0;
bs.Write( num1, min1, max1 ); // 12 bits (11 bits for 1000 plus 1 bit for negative sign)
bs.Write( num2, min2, max2, fltPrec ); // converts to 1679 int, 14 bits (maximum converted to int is 5000)
bs.Write( num3, min3, max3, dblPrec ); // precision is ignored here as min/max are too high to try to convert to an integer, so the value is stored using all 64 bits of the double
bs.Write( true ); // 1 bit
int num4;
float num5;
double num6;
bool checker;
bs.Read( out num4, min1, max1 ); // num3 = 287
bs.Read( out num5, min2, max2, fltPrec ); // num4 = 16.79, there is some loss of precision here
bs.Read( out num6, min3, max3, dblPrec ); // num6 = 9845216.1916526, no loss of precision
bs.Read( out checker ); // checker = true
int newNum;
bs.Read( out newNum, -100, 100 ); // newNum = 0 as there are no bits left in the BitStream
BitStream bs = new BitStream();
int min1 = -1000, max1 = 1000, num1 = 287;
float min2 = 0f, max2 = 50f, num2 = 16.78634f;
double min3 = double.MinValue, max3 = double.MaxValue, num3 = 9845216.1916526;
byte fltPrec = 2;
byte dblPrec = 0;
bs.Write( num1, min1, max1 ); // 12 bits (11 bits for 1000 plus 1 bit for negative sign)
bs.Write( num2, min2, max2, fltPrec ); // converts to 1679 int, 14 bits (maximum converted to int is 5000)
bs.Write( num3, min3, max3, dblPrec ); // precision is ignored here as min/max are too high to try to convert to an integer, so the value is stored using all 64 bits of the double
bs.Write( true ); // 1 bit
int num4;
float num5;
double num6;
bool checker;
bs.Read( out num4, min1, max1 ); // num4 = 287
bs.Read( out num5, min2, max2, fltPrec ); // num5 = 16.79, there is some loss of precision here
bs.Read( out num6, min3, max3, dblPrec ); // num6 = 9845216.1916526, no loss of precision
bs.Read( out checker ); // checker = true
int newNum;
bs.Read( out newNum, -100, 100 ); // newNum = 0 as there are no bits left in the BitStream
added 1633 characters in body
Source Link
Tim
  • 115
  • 1
  • 6
Loading
Tweeted twitter.com/StackCodeReview/status/750873451515224064
edited tags
Link
200_success
  • 145.6k
  • 22
  • 190
  • 479
Loading
Source Link
Tim
  • 115
  • 1
  • 6
Loading
lang-cs

AltStyle によって変換されたページ (->オリジナル) /