LING 408/508: Programming for Linguists Lecture 3 September 2nd Administrivia • Homework 1 graded • Today’s Topics: – Homework 1 Review – VirtualBox – Ubuntu install (also your Homework 2) Homework 1 Review • Recall the speed of light: • c = 2.99792458 x 108 (m/s) 1. Can a 4 byte integer be used to represent c exactly? 2. How much memory would you need to encode c using BCD notation? 3. Can the 64 bit floating point representation (double) encode c without loss of precision? Explain. 4. The 32 bit floating point representation (float) is composed of 1 bit sign, 8 bits exponent, and 23 bits coefficient (24 bits effective). Can it represent c without loss of precision? Homework 1 Review • Recall the speed of light: • c = 2.99792458 x 108 (m/s) 1. Can a 4 byte integer be used to represent c exactly? – 4 bytes = 32 bits – 32 bits in 2’s complement format – 231-1 = 2,147,483,647 – c = 299,792,458 Homework 1 Review • Recall the speed of light: • c = 2.99792458 x 108 (m/s) 2. How much memory would you need to encode c using BCD notation? – 9 digits – each digit requires 4 bits (a nibble) – BCD notation includes a sign nibble – total is 5 bytes Homework 1 Review • Recall the speed of light: • c = 2.99792458 x 108 (m/s) 3. Can the 64 bit floating point representation (double) encode c without loss of precision? Explain. – Recall significand precision: 53 bits (52 explicitly stored) – 253-1 = 9,007,199,254,740,991 – almost 16 digits Homework 1 Review • Recall the speed of light: • c = 2.99792458 x 108 (m/s) 4. The 32 bit floating point representation (float) is composed of 1 bit sign, 8 bits exponent, and 23 bits coefficient (24 bits effective). Can it represent c without loss of precision? – 224-1 = 16,777,215 – Nope VirtualBox • Virtual x86 machine(s) – install other operating systems (OSs) running inside a window, we’ll install Ubuntu (Linux) as a Guest OS • Free application at https://www.virtualbox.org Ubuntu 14.04 LTS* under VirtualBox under OS X 10.9.4 *LTS = Long Term Support Homework 2 • Your homework is to successfully install Ubuntu under VirtualBox on your computer this week (preferably: ready for next class) – this is different from partitioning your hard drive, installing Ubuntu in one of the partitions, and making your machine dual booting (although you could do that) … • I’ll walk through the live install Ubuntu here … • Assume VirtualBox + Extension Pack is installed – (I’m using version 4.3.14 now) VirtualBox • Download extension pack as well: • Enable it from VirtualBox Preferences… VirtualBox • • • • Step 1: download Ubuntu ISO image from http://www.ubuntu.com/download/desktop ISO image: this is an image of a CD. Choose 64 bits (recent machine). 32 bits for older machines. 64 bits Mac (for recent Macs) – for booting with a Mac (in BIOS emulation mode) Skip the donation page … VirtualBox • The file ubuntu-14.04-desktop-amd64+mac.iso takes considerable time to download (size: about 1GB) • We don’t boot off real cds anymore; the .iso file is a special file that can be interpreted as a virtual cd • ISO images: – Macs can mount ISO images. – Macs can’t boot off a multitrack ISO image; hence the special adm64+mac version. – some versions of Windows can’t mount an ISO image (without extra software). Install Microsoft’s Virtual CD-ROM Control Panel. • Next, we need to create the virtual machine on which we’re going to install Ubuntu on VirtualBox • Step 2: in VirtualBox, select New and give new virtual machine of type Linux a name dynamically allocated VirtualBox Disk Image VirtualBox • Need to add your .iso file in Settings > Storage: Select your downloaded .iso file VirtualBox • Confirmation: VirtualBox • Boot order, see Settings > System: – we need to boot off the virtual cd first in order to install Ubuntu onto the virtual hard disk you created. (After we’re done installing, we want to go back and change the boot order so we boot off the hard disk.) VirtualBox • Step 3: start your virtual machine, install Ubuntu: Ubuntu • Install extension pack: • No connection: Ubuntu • Press on: ask you for name, location, language etc. Ubuntu • Restart didn’t work. I shutdown the virtual machine. And started it again. Logged in and tried Firefox. Ubuntu • Since the network wasn’t active on install, Software Updater has plenty of stuff to do … • It’ll probably ask you for your password to do installation. • May ask you to restart Ubuntu • Guest Additions: – Devices > Insert Guest Additions CD image … Ubuntu • Display resolution: – 640 x 480 until Video Memory is increased in Settings > Display Ubuntu • Ubuntu Software Center – App store – (full screen to see Search box) • Software packages – Terminal: sudo apt-get install <pkg-name> – sudo prefix: means execute the apt-get command with superuser privileges (typically needed for packages) • How to find Terminal: use search Lock to Launcher Ubuntu • Terminal: The shell has a programming language – runs a shell: bash – enter commands: some are built-in to the shell, others are executable files in specified directories ($PATH), still others will require apt-get – simple commands: • • • • • • • pwd ls (ls -a) cd mkdir which name man name echo $SHELL print working directory list current directory (-a option: show . (dot) files too) change directory create a new directory the directory where command name is located display manual page for command name prints the shell ($ prefixes a variable) dpkg –get-selections – pre-defined environment variables: env – lots of packages are pre-loaded: wish, python, perl, etc.