Sample

int-5d78e2580a2b-I01

Remove line comments, block comments, and Javadoc

Matched original source

Lines119

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Scalabrino0.7110–1; higher is more readable
Dorn0.1090–1; higher is more readable
Mi0.5130–1; higher is more readable
LLOC41Logical lines; fewer is more readable
DeepSeek V4 Pro170–20; mean of three runs
GPT-6.1 Sol150–20; mean of three runs
BTTF0.4930–1; higher is more readable

Views

Source code

package com.google.common.math; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.Double.MAX_EXPONENT; import static java.lang.Double.MIN_EXPONENT; import static java.lang.Double.POSITIVE_INFINITY; import static java.lang.Double.doubleToRawLongBits; import static java.lang.Double.isNaN; import static java.lang.Double.longBitsToDouble; import static java.lang.Math.getExponent; import static java.lang.Math.max; import com.google.common.annotations.GwtIncompatible; import com.google.common.annotations.VisibleForTesting; import java.math.BigInteger; @GwtIncompatible final class DoubleUtils { private DoubleUtils() {} static final long SIGNIFICAND_MASK = 0x000fffffffffffffL; static final long EXPONENT_MASK = 0x7ff0000000000000L; static final long SIGN_MASK = 0x8000000000000000L; static final int SIGNIFICAND_BITS = 52; static final int EXPONENT_BIAS = 1023; static final long IMPLICIT_BIT = SIGNIFICAND_MASK + 1; static long getSignificand(double d) { checkArgument(isFinite(d), "not a normal value"); int exponent = getExponent(d); long bits = doubleToRawLongBits(d); bits &= SIGNIFICAND_MASK; return (exponent == MIN_EXPONENT - 1) ? bits << 1 : bits | IMPLICIT_BIT; } static boolean isFinite(double d) { return getExponent(d) <= MAX_EXPONENT; } static boolean isNormal(double d) { return getExponent(d) >= MIN_EXPONENT; } static double scaleNormalize(double x) { long significand = doubleToRawLongBits(x) & SIGNIFICAND_MASK; return longBitsToDouble(significand | ONE_BITS); } static double bigToDouble(BigInteger x) { BigInteger absX = x.abs(); int exponent = absX.bitLength() - 1; if (exponent < Long.SIZE - 1) { return x.longValue(); } else if (exponent > MAX_EXPONENT) { return x.signum() * POSITIVE_INFINITY; } int shift = exponent - SIGNIFICAND_BITS - 1; long twiceSignifFloor = absX.shiftRight(shift).longValue(); long signifFloor = twiceSignifFloor >> 1; signifFloor &= SIGNIFICAND_MASK; boolean increment = (twiceSignifFloor & 1) != 0 && ((signifFloor & 1) != 0 || absX.getLowestSetBit() < shift); long signifRounded = increment ? signifFloor + 1 : signifFloor; long bits = (long) (exponent + EXPONENT_BIAS) << SIGNIFICAND_BITS; bits += signifRounded; bits |= x.signum() & SIGN_MASK; return longBitsToDouble(bits); } static double ensureNonNegative(double value) { checkArgument(!isNaN(value)); return max(value, 0.0); } @VisibleForTesting static final long ONE_BITS = 0x3ff0000000000000L; }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.3526.302−116.368
Source linesThe number of non-empty source lines.119+47.6
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.152−7.727

Intercept 8.87 + feature contributions = -67.625 (log-odds).
Score = sigmoid(-67.625) = 0.

Score0.711

Feature contributions

FeatureValueContribution
(log-odds)
Indentation frequencyHow rapidly indentation changes from line to line.119+3.379
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.119−3.177
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.118−2.287
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.118.879+1.252
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.0−0.804
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.97.983−0.485
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.102−0.047

Intercept 0.07 + feature contributions = -2.099 (log-odds).
Score = sigmoid(-2.099) = 0.109.

Score0.513
Score41
Run 1

The code is well-structured and follows clear logical organization. Constants are grouped at the top with descriptive names and comments. Methods are concise and focused on single responsibilities. Nesting is minimal — only a few conditional branches with no deep indentation. The intent of each method is clear from naming and brief comments. However, the bigToDouble method contains a long block of bit-manipulation logic with multiple operations, which slightly reduces clarity despite explanatory comments. Line length and inline comments aid understanding, but the method could benefit from extracting helper methods or additional comments for complex rounding logic. Overall, the code is highly readable for low-level numeric utilities, with only moderate complexity in one section.

Run 2

The code is highly readable with clear structure, consistent sectioning, and purposeful naming aligned with the IEEE 754 domain. It uses flat logic in most methods, avoids deep nesting, and keeps actions granular—one meaningful operation per line. Comments clarify bit manipulation, which would otherwise be opaque. Minor deductions come from dense constants and bit operations that require domain knowledge, and some comment blocks could be slightly more concise. Overall, strong clarity of intent and clean organization make it easy for a reader familiar with floating-point formats to follow and trust.

Run 3

The code is generally well-structured and readable. It has clear constants with meaningful names, proper separation of concerns, and concise methods. The nesting is minimal, with flat conditional logic. Most lines perform a single action, and the reading flow is natural. However, the bigToDouble method is the weakest part: it has a dense block of bit manipulation with comments that explain 'what' but not always 'why', and several magic numbers (Long.SIZE - 1, SIGNIFICAND_BITS - 1) that require domain knowledge. Some comments are overly verbose while others are sparse. The overall clarity is good but slightly hindered by the inherent complexity of IEEE 754 bit operations.

Run 1

Code Structure: Focused utility methods and descriptive constants provide logical organization, though ONE_BITS is placed after methods rather than with other constants. Nesting: Minimal nesting and early returns keep control flow simple. Clarity of intent: Method names convey general purpose, but IEEE-754 bit manipulation and rounding logic require specialized knowledge; missing explanatory comments and abbreviated variables reduce clarity. Code length: Implementations are concise, but excessive blank lines unnecessarily expand the presentation. Action granularity: Most lines perform one assignment or operation, although the rounding condition combines several nontrivial checks. Reading flow: Methods generally progress naturally from input checks through calculations to results, but irregular spacing and unexplained bitwise expressions interrupt smooth reading.

Run 2

Code Structure: Well organized as a focused utility class with named constants and small, cohesive methods, although ONE_BITS is separated from related constants. Nesting: Shallow conditionals and early returns make control flow easy to follow. Clarity of intent: Method and constant names generally convey purpose, but significand manipulation and rounding logic require floating-point expertise; explanatory comments would help. Code length: Implementation is concise, but excessive blank lines create unnecessary visual length. Action granularity: Most lines perform one clear action, though the compound increment condition packs several rounding checks into one expression. Reading flow: Methods follow natural computational sequences, but irregular spacing and unexplained bit operations interrupt comprehension.

Run 3

Code Structure: Cohesive utility class with small, logically separated methods and descriptive constants. Nesting: Very shallow; early returns keep conversion logic mostly flat. Clarity of intent: Method names communicate their purposes, but IEEE-754 bit manipulation and rounding calculations require specialized knowledge and lack explanatory comments. Code length: Implementation is concise, although excessive blank lines add visual clutter. Action granularity: Most statements perform one action per line; the compound rounding condition is relatively dense. Reading flow: Generally natural, progressing from constants to helpers and conversion logic, but irregular whitespace and the late placement of ONE_BITS interrupt the flow.