Skip to main content

Numbers

  • Chapter
  • First Online:
Book cover C++ for Lazy Programmers
  • 4516 Accesses

Abstract

Numbers are what makes the computer's world go 'round, so let's examine ways to get the computer to handle those numbers for us.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 34.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    I’m lining up the =’s, you’ll notice. Neatness makes for easier reading.

  2. 2.

    There are maybe too many ways to declare constant values in C++: const, enum, constexpr, inline constexpr, static const...but we’ll get to that later.

  3. 3.

    If you want to add 1, rather than some other number, there’s a special “increment” operator just for that:

    ++seasonsOfAmericanIdol;

    We’ll see that again in Chapter 5, along with “decrement” (--).

  4. 4.

    Include files inherited from C++’s ancestor C, under current conventions, start with a “c”: cmath and cstdlib, for example.

  5. 5.

    We cast to int to avoid that conversion warning mentioned in the preceding “Antibugging.” The time function returns a time_t (whatever that is); we’ll force it to be an int.

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Will Briggs

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Briggs, W. (2019). Numbers. In: C++ for Lazy Programmers. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5187-4_3

Download citation

Publish with us

Policies and ethics