APPENDIX B

Numeric Encoding

Introduction

This appendix explains various ways in which numbers can be represented and encoded in computer systems in general, and JavaScript in particular. It covers binary, decimal, and hexadecimal numerals, the representation of noninteger values, and the details behind JavaScript’s belief that 0.1 + 0.2 ≠ 0.3.

Place Value

A number is an abstraction of a quantity; a numeral is a representation of a number. For example, the number seventy-six can be denoted by the Roman numeral LXXVI, the Hindu-Arabic decimal numeral 76, the Hindu-Arabic hexadecimal numeral 4C, or the Hindu-Arabic binary numeral 1001100.

Hindu-Arabic systems represent numerals as a sequence of digits with an optional radix point. The number of ...

Get Programming with JavaScript: Algorithms and Applications for Desktop and Mobile Browsers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.