Number lines blank printable: Printable Blank Number Line — Class Playground

Posted on

Blank Number Lines — Printable

  • Grades

    Grades:  1 — 6

Print a set of open number lines to help you teach a variety of math skills.

Print a Pack of Blank Number Lines!

Are you looking for a versatile tool to support your math instruction? Look no further than the humble number line. While it may seem like a simple tool for counting and basic arithmetic, number lines can be used in a variety of creative ways to enhance students’ understanding of more advanced math concepts.

What Can You Teach on a Number Line?

You might think a number line is one of those basic tools that is really only used with primary-grade students for learning to count, add, and subtract. But it can be so much more! Here are a few more things you can do with a blank number line!

  1.  These blank number lines are perfect for showing students how to locate fractions on the number line, partition an open number line, compare and order fractions, and perform operations with fractions.
  2. Just like fractions, the blank number line is a handy tool to help you teach students about decimals. Use the number line to locate, compare, order, and solve problems.
  3. An extended blank number line can be used to teach negative numbers by showing students how to locate negative numbers on the number line and perform operations with negative numbers.
  4. In upper grades, number lines are used to teach algebraic equations by showing students how to represent variables and solve equations using the number line.
  5. The number line is also a great tool to help you teach patterns and sequences. With a number line, you can have your students identify and extend number patterns on the number line.

Download and Print Your Open Number Lines

This resource download includes a single-page group of six open number lines that are perfect for use in a variety of math lessons.

This resource prints as a landscape-formatted black-and-white PDF document. Simply click the download button, print your copies, and you’re ready to teach! You can make your number lines reusable by slipping them into a clear sleeve/sheet protector and having your students write on them with a dry-erase marker.

  • teaching resource

    Addition Strategies Task Cards

    Practice using the jump strategy, break apart strategy, compensation strategy and 100s chart strategy with this set of task cards.

    9 pages

    Grade

    2 — 3

  • teaching resource

    Part Part Whole Word Problem Task Cards and Worksheet

    Explore these animal-themed part-part-whole word problems that will open discussions with your young mathematicians.

    15 pages

    Grade
    1

  • teaching resource

    Bridge to Ten Addition Strategy Task Cards

    Help students quickly bridge to ten to assist with their addition strategies using linking cubes.

    20 pages

    Grade
    1

  • Free

    teaching resource

    Find 20 Addition Strategy Task Cards

    Practice finding 20 with this set of linking cube task cards.

    1 page

    Grade
    1

  • teaching resource

    Addition Strategies Exit Tickets

    Assess student knowledge of different addition strategies with these printable exit tickets.

    31 pages

    Grade

    2 — 3

  • teaching resource

    Addition Strategy Mats

    Practice using a variety of addition strategies to add 2-digit numbers.

    28 pages

    Grade

    2 — 3

  • Free

    teaching resource

    Adding with Strip Diagram Cut and Paste Worksheet

    Practice adding two digit numbers using the strip diagram with this cut and paste worksheet.

    2 pages

    Grade
    2

  • teaching resource

    Addition Strategy Spin Game

    Have some fun all while practicing different addition strategies with this fun classroom game.

    9 pages

    Grade

    2 — 3

  • teaching resource

    Skip Counting for Multiplication Interactive Activity

    Teach multiplication using the skip counting strategy with this fun, interactive digital teaching resource!

    1 page

    Grade
    3

  • teaching resource

    Skip Counting and Multiplication Matching Game

    Use this resource as a hands on-task to practice using skip counting to solve multiplication expressions.

    12 pages

    Grade

    2 — 3

Blank Number Line Printable Form — Fill Out and Sign Printable PDF Template

Establishing secure connection…Loading editor…Preparing document…

    org/BreadcrumbList»>

  • Electronic Signature
  • Forms Library
  • Other Forms
  • All Forms
  • Blank Number Lines Printable PDF Form

Use a blank number line printable template to make your document workflow more streamlined.

______________________________
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
© 2013 National Council of Teachers of Mathematics
http://illuminations.nctm.org
REPRODUCIBLE
Table 3.5:
Domain-by-Domain Cross-Grade Analysis
Grade K
Grade 1
Grade 2
Grade 3
Counting and Cardinality (K only)
Know number names
and the…

Show details

We are not affiliated with any brand or entity on this form.

How it works

Open the blank numberline and follow the instructions

Easily sign the blank number lines with your finger

Send filled & signed blank number lines pdf or save

Rate the blank number line printable pdf

4.7

Satisfied

Rate Blank Number Lines Printable Pdf as 5 stars

Rate Blank Number Lines Printable Pdf as 4 stars

Rate Blank Number Lines Printable Pdf as 3 stars

Rate Blank Number Lines Printable Pdf as 2 stars

Rate Blank Number Lines Printable Pdf as 1 stars

57 votes

What makes the blank numberline legally binding?

As the society takes a step away from office work, the execution of paperwork increasingly occurs electronically. The blank number lines isn’t an any different. Dealing with it utilizing electronic tools differs from doing so in the physical world.

An eDocument can be regarded as legally binding provided that certain needs are fulfilled. They are especially vital when it comes to signatures and stipulations associated with them. Entering your initials or full name alone will not guarantee that the organization requesting the sample or a court would consider it executed. You need a reliable tool, like signNow that provides a signer with a electronic certificate. In addition to that, signNow keeps compliance with ESIGN, UETA, and eIDAS — major legal frameworks for eSignatures.

How to protect your blank number lines pdf when completing it online?

Compliance with eSignature regulations is only a portion of what signNow can offer to make form execution legitimate and safe. In addition, it gives a lot of possibilities for smooth completion security smart. Let’s rapidly run through them so that you can stay certain that your blank number line printable pdf remains protected as you fill it out.

  • SOC 2 Type II and PCI DSS certification: legal frameworks that are set to protect online user data and payment information.
  • FERPA, CCPA, HIPAA, and GDPR: major privacy standards in the USA and Europe.
  • Two-factor authentication: provides an extra layer of security and validates other parties’ identities through additional means, like an SMS or phone call.
  • Audit Trail: serves to capture and record identity authentication, time and date stamp, and IP.
  • 256-bit encryption: sends the information safely to the servers.

Submitting the blank number line pdf with signNow will give greater confidence that the output document will be legally binding and safeguarded.

Handy tips for filling out Blank number line printable online

Printing and scanning is no longer the best way to manage documents. Go digital and save time with signNow, the best solution for electronic signatures. Use its powerful functionality with a simple-to-use intuitive interface to fill out Blank numberline online, e-sign them, and quickly share them without jumping tabs. Follow our step-by-step guide on how to do paperwork without the paper.

Quick steps to complete and e-sign Blank number lines online:

  1. Use Get Form or simply click on the template preview to open it in the editor.
  2. Start completing the fillable fields and carefully type in required information.
  3. Use the Cross or Check marks in the top toolbar to select your answers in the list boxes.
  4. Utilize the Circle icon for other Yes/No questions.
  5. Look through the document several times and make sure that all fields are completed with the correct information.
  6. Insert the current Date with the corresponding icon.
  7. Add a legally-binding e-signature. Go to Sign -> Add New Signature and select the option you prefer: type, draw, or upload an image of your handwritten signature and place it where you need it.
  8. Finish filling out the form with the Done button.
  9. Download your copy, save it to the cloud, print it, or share it right from the editor.
  10. Check the Help section and contact our Support team if you run into any problems while using the editor.

We understand how stressing filling in forms can be. Gain access to a HIPAA and GDPR compliant service for maximum efficiency. Use signNow to electronically sign and send out Blank number lines pdf for collecting e-signatures.

be ready to get more

Create this form in 5 minutes or less

Get Form

Video instructions and help with filling out and completing Blank Number Lines Printable Pdf Form

Find a suitable template on the Internet. Read all the field labels carefully. Start filling out the blanks according to the instructions:

Instructions and help about printable 20 to 20 number line

hi friends kelly here from freebiefindingmom. com and today i wanted to share with you just some of the math educational resources that we have over on freebiefindingmom.com and these are all completely free everything i’m going to show you you’ll be able to download when you head over to the website um right then and there you’ll be able to grab these downloads completely free i’m not going to go through all of the math resources that we have but i’m going to go through some of them that i hope will help you out whether you are a teacher maybe a homeschool mom or just a parent you know trying to help your kids get through school and so that’s why i put these together for you so the first things that i want to highlight are our number tracing worksheets so we have number tracing worksheets again completely free to download these focus on the numbers one through ten that can help them if you have young kids maybe starting to recognize their numbers and maybe even starting to write out t

Create this form in 5 minutes!

Use professional pre-built templates to fill in and sign documents online faster. Get access to thousands of forms.

Get Form

How to create an eSignature for the blank number lines printable pdf

Speed up your business’s document workflow by creating the professional online forms and legally-binding electronic signatures.

How to create an electronic signature for a PDF online

How to create an electronic signature for a PDF in Google Chrome

How to create an e-signature for signing PDFs in Gmail

How to create an e-signature right from your smartphone

How to create an e-signature for a PDF on iOS

How to create an e-signature for a PDF on Android

How to create an electronic signature for a PDF online

How to create an electronic signature for a PDF online

blank number lines pdf solution to eSign blank number line printable? signNow combines ease of use, affordable price and safety in one online service, all without forcing additional software programs on you. All you need is smooth web connection and a device to work on.

Stick to the step-by-step recommendations listed below to electronically sign your blank numberline:
  1. Choose the paper you want to eSign and click Upload.
  2. Click the My Signature button.
  3. Decide on what kind of electronic signature to generate. You will find three variants; a drawn, typed or uploaded eSignature.
  4. Make your eSignature and click the OK button.
  5. Hit Done.

After that, your blank number lines is ready. All you have to do is save it or send the document via email. signNow makes eSigning much easier and a lot more convenient since it provides users with a range of extra features like Invite to Sign, Merge Documents, Add Fields, and many others. And because of its multi-platform nature, signNow works well on any device, desktop computer or mobile, irrespective of the OS.

How to create an electronic signature for a PDF in Google Chrome

How to create an electronic signature for a PDF in Google Chrome

blank number lines pdf has acquired its global popularity because of its variety of helpful features, extensions and integrations. As an example, web browser extensions make it possible to keep all of the instruments you need a click away. Due to the collaboration between signNow and Chrome, find its extension in the Web Store and then use it to eSign blank number line printable in your web browser.

The steps listed below can help you make an eSignature for signing blank numberline in Chrome:
  1. Find the extension Google Web Store and push Add.
  2. Sign in to your registered account.
  3. Click on the link to the document you would like to eSign and select the Open in signNow option.
  4. Use the My Signature tool to make a unique eSignature.
  5. Insert it anywhere on the page and click on Done.

When you’ve finished signing your blank number lines, choose what you should do after that — save it or share the doc with other parties involved. The signNow extension provides you with a variety of features (merging PDFs, adding numerous signers, etc. ) to guarantee a better signing experience.

How to create an e-signature for signing PDFs in Gmail

How to create an e-signature for signing PDFs in Gmail

blank number lines pdfinesses have gone digital, papers are sent through email. That applies to agreements and contracts, tax forms and virtually any other paper that will require a signature. The issue comes up ‘How can I eSign the blank number line printable I got straight from my Gmail without any third-party apps? ’ The answer is clear — use the signNow Chrome extension.

Below are several simple actions to get your blank numberline eSigned without the need of leaving your Gmail profile:
  1. Go to the Chrome Web Store and add the signNow extension to your browser.
  2. Sign in to the account you’ve created.
  3. Click on the email you got with the documents that require signing.
  4. Select Sign from the solution’s sidebar and make your eSignature.
  5. Press the Done button and the electronic signature is created. The eSigned document will be attached to the draft electronic mail created by signNow’s eSignature solution.

The sigNow extension was made to assist active people such as you to decrease the burden of signing documents. Begin eSigning blank number lines using our tool and join the numerous satisfied users who’ve already experienced the advantages of in-mail signing.

How to create an e-signature right from your smartphone

How to create an e-signature right from your smartphone

blank number lines pdfnd tablet PCs are in fact a complete business alternative to desktop and laptop PCs. It is possible to take them everywhere and use them on the run provided that you have got a smooth connection to the internet. Consequently, the signNow web app is important for completing and putting your signature on blank number line printable on the run. Within seconds, get an digital document with a legally-binding eSignature.

Get blank numberline eSigned from your mobile phone following these 6 steps:
  1. Enter signnow.com in your phone’s web browser and log in to your profile. Get registered if you don’t have an account yet.
  2. Search for the document you want to eSign from your gadget and upload it.
  3. Open the doc and select the page that must be eSigned.
  4. Hit My Signature.
  5. Create your electronic signature, and apply it to the document.
  6. Make sure that everything’s fine and press Done.

The entire process can last a few seconds. You can download the signed [Form] to your device or share it with other parties involved with a link or by email, as a result. Because of its cross-platform nature, signNow is compatible with any device and any OS. Select our eSignature solution and say goodbye to the old times with affordability, security and efficiency.

How to create an e-signature for a PDF on iOS

How to create an e-signature for a PDF on iOS

blank number lines pdf like an iPhone or iPad, effortlessly create e- signatures for signing a blank number line printable in PDF formatting. signNow has paid close attention to iOS device users and created an app only for them. To get it, go to the AppStore and enter signNow in the search field.

To eSign a blank numberline straight from your iPhone or iPad, just keep to these short recommendations:
  1. Install the signNow application on the iOS gadget.
  2. Create a free account using your electronic mail or register by means of Google or Facebook.
  3. Import the PDF file you have to eSign. Do that by getting it from your internal storage or the cloud.
  4. Select the area you wish to eSign and then click Insert Initials or Insert Signature.
  5. Draw your initials or signature, insert it in the corresponding field and save the modifications.

After it’s signed it’s up to you regarding how to export your blank number lines: save it to your mobile device, upload it to the cloud storage or send it to other people via e-mail. The signNow application is just as productive and powerful as the online app is. Connect to a strong connection to the internet and begin executing forms with a court-admissible eSignature in minutes.

How to create an e-signature for a PDF on Android

How to create an e-signature for a PDF on Android

blank number lines pdf rather popular among mobile users, the market share of Android OS smartphones and tablets is much bigger. Consequently, signNow has developed a separate app for mobile devices working on Android. Easily find the mobile app in the Play Market and install it for putting your signature on your blank number line printable.

To add an e- signature to a blank numberline, keep to the simple guidelines listed below:
  1. Sign in to your signNow account. In case you haven’t created one yet, you are able to do it, by means of Facebook or Google.
  2. Import the PDF file you want to eSign by means of your digital camera or cloud storage by choosing the + symbol.
  3. Select the area in which you want to insert your electronic signature and then create it right in the popup window.
  4. Confirm and add it by clicking on the symbol and then save the modifications.
  5. Save the eSigned file.

If you wish to share the blank number lines with other parties, it is possible to send it by email. With signNow, it is possible to eSign as many documents in a day as you need at a reasonable cost. Begin automating your signature workflows right now.

Related links to Blank Number Lines Printable Pdf

People also ask

  • How do you make an open number line?

    0:28 2:23 2nd Grade Math: Addition — Open Number Line (2-digit . .. — YouTube YouTube Start of suggested clip End of suggested clip 10 plus 10 plus 10 45 plus 10 equals 55 plus 10 equals 65 plus 10 equals 75. Next I will add twoMore10 plus 10 plus 10 45 plus 10 equals 55 plus 10 equals 65 plus 10 equals 75. Next I will add two ones and represent that with a smaller jump and label. 1 2 plus 1 plus 1 75 plus 1 equals 76.

  • Why use an empty number line?

    Students who use the empty numberline are able to create a mental image of the strategies they are being taught and can then make the leap more easily towards mental calculations without paper.

  • What is a number line PDF?

    A number line can be a powerful tool for learning about negative numbers, ratios or just introductory addition and subtraction operations. The number line PDFs on this page include various ranges (10, 12, 15, 20, 15 and 100) in both starting from zero as well as negative ranges.

  • What is an example of empty number line?

    The empty number line allows students to see the variety of ways that the same question can be solved. For example, to solve 157 + 36 a student may begin at 157 and add 30, then 6 or start at 157 and add 3 to get to the next multiple of ten (160) and then add 33.

  • How do you make an empty number line?

    0:43 4:30 Empty Number Line Strategy — YouTube YouTube Start of suggested clip End of suggested clip Using an empty number line means you start at the starting number 82. And you count on my ones endsMoreUsing an empty number line means you start at the starting number 82. And you count on my ones ends or hundreds.

  • What is a blank number line?

    A number line with no numbers. The number line is a visual representation to allow children to «jump» from the starting number of a calculation, to the end number, in increments, to allow them to work out the difference.

  • What is a number line without tick marks?

    Blank Number Line – No Tick Marks Represent whole numbers as lengths from 0 on a number line diagram with equally spaced points corresponding to the numbers 0, 1, 2, …, and represent whole-number sums and differences within 100 on a number line diagram.

be ready to get more

Get this form now!

Get Form

If you believe that this page should be taken down, please follow our DMCA take down process here.

Sign up with Google

You have been successfully registered in signNow

Check signNow
Back to form editing

Unexpected blank page printing — Office

Twitter

LinkedIn

Facebook

E-mail address

  • Article
  • Applies to:
    Microsoft Office Excel 2003, Microsoft Office Excel 2007, Excel 2010, Excel 2013

Symptoms

In Microsoft Excel, when you print a worksheet, pages that are completely blank may print unexpectedly.

Cause

This problem can occur for the following reasons:

  • The only data on the page is in cells formatted to be blank.

    Cells formatted as blank include cells with white fonts, zeros as blank cells, three semicolons (see Example 1 in the More Information section), etc.

  • A cell on a page contains an error and errors are displayed when printing blank pages

  • Any pages containing data (including the first two conditions specified here) will display blank pages before them.

  • The sheet contains graphics objects located in unexpected areas of the sheet.

  • Sheet contains hidden columns with manual page breaks

    These objects can be very small, formatted with white fonts, etc.

Pages containing hidden rows or columns are not printed (unless there is other data on the page) and are not intermediate pages.

Workaround

To work around this issue, follow these steps.

  1. From the File menu, choose Print.

    Note . In Excel 2007, click Microsoft Office Button and then click Print .

  2. In the Print Range section, select only the page or pages you want to print.

Both of the following examples require the following steps:

  1. Start Excel and create a new workbook.
  2. In cell A1, type Test.

Example 1: Cell formatted as blank

  1. In cell M85, type Test and press ENTER.

  2. Select cell M85.

  3. From the Format menu, choose Cells.

    Note . In Excel 2007, click Format in the Cells group on the Home tab, and then click Format Cells.

  4. On the Number tab, select All Formats from the Number Format list.

  5. In the Type field, delete the selection (press the BACKSPACE key to remove the selection) and then type ;;; (three semicolons).

  6. Click OK.

    Cell M85 is hidden.

  7. From the File menu, choose Preview.

    Note . In Excel 2007, click Microsoft Office Button , point to Print , and then click Preview .

    Note that page 1 contains not only data, but also three blank pages. These include a page with a hidden cell and intermediate pages.

Example 2 Blank Page Printing Errors

  1. In cell M85, enter the following formula:

    =1/0

    A divide-by-zero error message is displayed.

  2. On the File menu, click Page Setup.

    Note . In Excel 2007, click the Page Setup Dialog Box Launcher in the Page Setup group on the Page Layout 9 tab0070 .

  3. On the Layout tab, under Print, in the Cell Error drop-down list, click Empty<"> .

  4. Click Preview.

    Note that page 1 contains not only data, but also three blank pages.

Data Types — C++ Basics

C++ is a statically typed language. Every variable must have a well-defined data type at compile time. For each data type, it is known in advance how much memory space a variable of this type occupies.

In this section, we’ll introduce some basic data types and the concept of variable scope.

Scope

In C++ there is a concept of scope of a variable. This scope is limited to the block of code in which the variable is defined. Consider an example:

 #include 
int a = 1; // global variable
int main() {
    int b = 2; // local variable
    {
        int c = 3; // local variable inside the block
        std::cout << a << " " << b << " " << c << "\n"; // correct
    }
    // This line will not compile
    // because variable c is not defined in this scope:
    std::cout << c << "\n";
}
 

In this example, there are three scopes:

  • global, in which the variable a is defined;
  • function body main , in which the variable is defined b ;
  • the inner block in which the variable is defined c .

In the last line of the example, the variable c is not available because its scope has already ended. In the event of a name collision, the compiler always chooses the most nested scope.

Consider an example:

 #include 
int main() {
    int x = 1;
    std::cout << x << "\n"; // prints 1
    {
        int x = 2; // new variable, has nothing to do with the previous x
        std::cout << x << "\n"; // prints 2
    }
    std::cout << x << "\n"; // print 1 again
}
 

Initialization of local variables

Local variables of simple types, such as int , are not initialized to zero by default. The compiler simply allocates bytes on the stack for them, but it doesn't have to fill them in any way. This is one of the C++ principles: we don't have to pay for not using .

The following code snippet can print anything:

 #include 
int main() {
    intx;
    std::cout << x << "\n"; // undefined behavior!
    int y;
    std::cin >> y; // and this is a valid scenario
}
 

The g++ and clang++ compilers generally give warnings about reading uninitialized variables when using the -Wall 9 option= 0
1 warning generated.

Note that std::string is a complex type and variables of this type are always initialized to an empty string by default. So there is no need to write std::string s = ""; . Just write std::string s; .

Simple data types

We are already familiar with the int type. Let's look at other fundamental data types in C++. These are the so-called integral types and types for real numbers.

 int main() {
    char c = '1'; // symbol
    bool b = true; // boolean variable, takes the values ​​false and true
    int i = 42; // integer (usually takes 4 bytes)
    short int i = 17; // short integer (occupies 2 bytes)
    long li = 12321321312; // long integer (usually 8 bytes)
    long long lli = 12321321312; // long integer (usually 8 bytes)
    float f = 2.71828; // fractional floating point number (4 bytes)
    double d = 3.141592; // double precision fractional number (8 bytes)
    long double ld = 1e15; // long fractional (usually 16 bytes)
}
 

Note that characters, unlike strings (that is, arrays of characters), are written in apostrophes, not quotes. In the example above, we write the unit character to the variable c . In fact, the ASCII code of this character is stored in memory, which is equal to 49.

Recall that each data type occupies a known number of bytes of memory in advance. The C++ language standard does not impose strict restrictions on the size of types, they may differ for different platforms and compilers.

We will describe below what to do with this feature. In the meantime, note that you can find out the size of a variable or type at compile time using the sizeof operator.

For example, on a 64-bit Linux system, the compiler clang++ uses the following sizes for types:

 int main() {
    std::cout << "char: " << sizeof(char) << "\n"; //  1
    std::cout << "bool: " << sizeof(bool) << "\n"; //  1
    std::cout << "short int: " << sizeof(short int) << "\n"; // 2 (default >= 2)
    std::cout << "int: " << sizeof(int) << "\n"; // 4 (default >= 2)
    std::cout << "long int: " << sizeof(long int) << "\n"; // 8 (default >= 4)
    std::cout << "long long int: " << sizeof(long long) << "\n"; // 8 (default >= 8)
    std::cout << "float: " << sizeof(float) << "\n"; //  4
    std::cout << "double: " << sizeof(double) << "\n"; //  8
    std::cout << "long double: " << sizeof(long double) << "\n"; // 16
}
 932-1
}
 

The minimum and maximum value that can fit in a given numeric type can be obtained like this:

 #include 
#include  // needed for numeric_limits
int main() {
    // calculate for type int:
    std::cout << "minimum value: " << std::numeric_limits::min() << "\n"
              << "maximum value: " << std::numeric_limits::max() << "\n";
}
 

This example on a 64-bit Linux system will print:

minimum value: -2147483648
maximum value: 2147483647
 

The above examples of the output of the operator sizeof are correct for 64-bit architectures, which are widespread today. However, if we compiled and ran such a program on a computer with a 32-bit architecture, we would get different results. For example, sizeof(long int) would become 4, while on modern computers we would get 8. There are also embedded systems that can also be written in C++. There, the bitness of the architecture can be even less than 32.

In the standard library header file cstdint there are integer types with a fixed size: 6_t / uint16_t

  • int32_t / uint32_t
  • int64_t / uint64_t
  • The number in the type name indicates the number of bits used for storage in memory. For example, int32_t contains 32 bits (4 bytes) and often corresponds to type int . If the system does not support some type, then the program simply will not compile with it.

    Integer type overflow

    Standard numeric types have a limited size and a limited set of allowed values. 32
    std::cout << a * a << "\n"; }

    In this example, the expression a * a will have the same type as the arguments. What is actually computed depends on the signedness of the type.

    Unsigned types can safely overflow: calculations will be performed modulo the appropriate power of two. In other words, only the least significant bits of the result will be taken into account:

     int main() {
        unsigned int x = 0; // on 64-bit platform sizeof(x) == 4
        unsigned int y = x - 1; // 4294967295, i.e. 2**32 - 1
        unsigned int z = y + 1; // 0
    }
     

    Conversely, for signed types, overflow leads to so-called undefined behavior (UB, undefined behavior).

    This situation is not considered a compilation error (indeed, at the compilation stage, the values ​​of variables may not yet be known). But in this case, the C++ standard ceases to guarantee anything about the behavior of the program. Compilers can use such cases to optimize programs, relying on developers to write code correctly and never allow undefined behavior. Further, we will meet other cases of undefined behavior.

    Unsigned types should be used when dealing with bitsets. In other cases, it is preferable to use signed types .

    Arithmetic operations

    The binary operations + , - and * work on numbers in the standard way. The result of the division operation / applied to integers is always rounded towards zero. Thus, for positive numbers, the operation / returns an incomplete quotient. The remainder of division of integers can be obtained using the operation % .

     int main() {
        int a = 7, b = 3;
        int q = a / b; // 2
        int r = a % b; // 1
    }
     

    If you want to get an ordinary quotient during division, then one of the arguments must be cast to a real type (for example, double ) using the operator static_cast :

     int main() {
        int a = 6, b = 4;
        double q = static_cast(a) / b; // 1. 5
    }
     

    Could have been written a little more concisely: double q = a * 1.0 / b; . Then the argument conversion would happen implicitly.

    Arithmetic operations on characters and comparison of characters with each other are actually operations on their ASCII codes:

     #include 
    int main() {
        char c = 'A';
        c += 25; // increase the ASCII code of the character by 25
        std::cout << c << "\n"; // Z
    }
     

    ASCII table with hexadecimal character codes. The high hexadecimal digit is on the left, the low hexadecimal digit is on the right. The so-called control characters, which usually do not have a graphical representation, are highlighted in color.

    Operation + in relation to strings means concatenation (that is, gluing). This is an example of an operator overload : the original addition operator in the standard library for string has been given a new meaning.

     #include 
    int main() {
        std::string a = "Hello, ";
        std::string b = "world!";
        std::string c = a + b; // Hello world!
    }
     

    For every binary operation (e. g. + ) there is an equals version ( += ) for the case where the left argument is the same as the variable to which the result is assigned:

     int main() {
        int x = 5;
        x += 3; // x = x + 3
        x *= x; // x = x * x
    }
     

    Finally, there are operators ++ and -- to increment or decrement a variable by one. They are prefix and postfix. The difference lies in the value of the expression, which will be evaluated when such an operator is applied. We'll look at this later, but for now, let's get used to using the default prefix operator for regular numbers:

     int main() {
        int x = 5;
        ++x; // 6
        --x; // 5 again
    }
     

    Floating point numbers

    C++ has three built-in types for writing fractional numbers: float (4 bytes), double (8 bytes), and long double (16 or 8 bytes, depending on the platform) ). In most cases, the recommended type is double . Type float is reasonable to use where huge arrays of numbers are processed, and there is a need to save memory.

    In general, the storage of fractional numbers in C++ is based on the IEEE 754 standard. A number is represented as a binary fraction in scientific notation: the sign bit, exponent, and mantissa are stored separately.

    This representation compares favorably with fixed-point numbers, which store a fixed number of digits. It allows, albeit with varying degrees of accuracy, to represent numbers that differ by orders of magnitude.

    When working with rational numbers, the denominator of which is not a power of two, representation errors inevitably arise. In the next section, we will discuss how to compare such numbers.

    Automatic type inference

    The C++ compiler can automatically infer the type of a variable from the value assigned to it. To do this, instead of type, you need to write the keyword auto :

     int main() {
    auto x = 42; // int
    auto pi = 3.

    By alexxlab

    Similar Posts