Skip to content

Latest commit

 

History

History
81 lines (44 loc) · 2.4 KB

lecture26-finale-puzzling.md

File metadata and controls

81 lines (44 loc) · 2.4 KB

Lecture 26 A Puzzling Finale

Implement Binary Search

implement_binary_search

integer_overflows_for_large_values_of_low_and_high

lessons

Java CAFEBABE

  • Java compilers make Java source code into bytecode
  • All Java classes start with the word CAFEBABE
  • $(CAFEBABE){16} = (3405691582){10}$

why_cafebabe

A Big Delight in Every Byte

a_big_delight_in_every_byte

another_look_bytes_are_signed

a_possible_fix_to_byte_cast

The Moral of Byte

the_moral_of_byte

Sordid Sort

sordid_sort

  • The answer should be unspecified:
  • In practice, [2000000000, -2000000000, 0]

another_bug_for_sordid_sort

a_possible_fix_for_sordid_sort

The Moral of Integer

the_moral_of_integer_1

the_moral_of_integer_2

Indecision

indecision

  • It returns false

The Moral of Indecision

the_moral_of_indecision

Long Division

long_division

  • It returns 5
  • Since MICROS_PER_DAY >> Integer.MAX_VALUE

The Moral of Long Division

the_moral_of_long_division

It's Elementary

its_elementary

  • The answer should be 17777 43878
  • 1 is the numeral one
  • l is the lower case letter el
  • $01234$ is an octal literal equal to $1,234_8$, which is 668

The Moral of Elementary

the_moral_of_elementary