October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Line of Code: What LOC Means and How It Is Counted

LOC measures source software, but physical lines, logical statements, blank lines, and comments can all be counted differently. Here is how to read the number.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A line of code (LOC) is a unit for measuring source software, but there is no single counting rule that applies everywhere. A physical count follows text line breaks; a logical count tries to count statements or other language-level units. To interpret an LOC figure, check which convention and inclusion rules were used.

What is a line of code?

In physical counting, a line is a segment of source text bounded by the applicable line ending or by the beginning or end of a file. This means a physical LOC count measures text layout, not necessarily the number of instructions a program performs. NIST’s measurement glossary documents multiple plausible definitions, so the acronym alone does not settle what a reported number means.

As an Amazon Associate I earn from qualifying purchases.

Physical LOC and logical LOC are different

Physical lines

Physical LOC follows line boundaries in the source file. A statement split over several lines can count as several physical lines, while a line containing multiple statements can count as one physical line.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Logical lines or statements

Logical LOC (sometimes abbreviated LLOC) aims to count language-level units, often statements, rather than text lines. Its meaning varies: it may mean statements, continuation-joined lines, or noncommented lines. A single statement can span multiple physical lines, and one physical line can contain multiple statements, so physical and logical totals can differ.

The loccount manual describes LLOC as source lines with statement-terminating punctuation, while noting that this approach is suitable only for languages whose syntax supports it. Treat “logical LOC” as a convention that needs its own definition, not as a universally fixed alternative to physical LOC.

Which lines count?

A count depends on whether it includes blank lines, comment-only lines, and lines containing both code and comments. NIST’s glossary uses CLOC for a line containing only comments and whitespace or an empty line, and NCLOC for a LOC that is not a CLOC. Under that terminology, LOC = NCLOC + CLOC. Other frameworks may use “SLOC” for a count that excludes blank and comment lines, another reason to state the counting rules rather than rely on an acronym.

  • Blank lines: may be included in a physical count, or excluded from a noncommented count.
  • Comment-only lines: may be counted separately or omitted, depending on the measure.
  • Mixed code-and-comment lines: may count as code. The CLOC documentation counts these lines as code.

Comment detection is not always exact. CLOC warns that it does not fully parse every target language; comment markers inside strings or here-documents can therefore be mistaken for actual comments. Its results describe that tool’s behavior, not a universal standard.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why LOC counts are useful—and limited

LOC is a concrete software-size measure that can be collected statically. NASA discusses LOC as a common size measure and an input to software cost estimation. But a count does not directly establish software quality, complexity, productivity, or development effort.

The same algorithm can have very different LOC totals in different implementations, and formatting, language, and counting rules affect the result. The GAO guide to software cost estimating cautions that there is no standard definition of what should count; the same functionality can produce different totals depending on language and programmer. LOC can support a comparison or estimate only when its scope and rules are clear.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to make an LOC figure interpretable

When publishing or comparing a count, report enough detail for someone else to understand what was measured:

  • Whether the figure is physical LOC, logical LOC, NCLOC, or another defined measure.
  • The programming languages and files included.
  • Whether blank lines, comment-only lines, and mixed code/comment lines count.
  • The counter and version, including relevant language or parser limitations.
  • For project-size estimates, how generated, copied, and modified code is treated.

These distinctions matter in cost models too. The COCOMO II Model Definition Manual, Version 2.1 uses logical source statements as its standard LOC input and provides a checklist to make counting rules consistent. That is a model-specific convention, not a universal definition of LOC.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.