From 9d5ec5e3bc01c6174dea048e118edee579c36565 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 7 Feb 2026 23:06:23 +0900 Subject: fix(style): fix codeblock style for rouge --- .../index.html | 61 ++++++++++------------ 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'services/nuldoc/public/blog/posts/2025-10-31/representing-single-value-with-half-open-float-interval') diff --git a/services/nuldoc/public/blog/posts/2025-10-31/representing-single-value-with-half-open-float-interval/index.html b/services/nuldoc/public/blog/posts/2025-10-31/representing-single-value-with-half-open-float-interval/index.html index 2c383346..535e9e49 100644 --- a/services/nuldoc/public/blog/posts/2025-10-31/representing-single-value-with-half-open-float-interval/index.html +++ b/services/nuldoc/public/blog/posts/2025-10-31/representing-single-value-with-half-open-float-interval/index.html @@ -15,7 +15,7 @@ 浮動小数点数の半開区間で単一値を表現する|REPL: Rest-Eat-Program Loop - +
@@ -152,9 +152,8 @@ 1p のビット列での表現を見てみよう。

-
1 = 0011111111110000000000000000000000000000000000000000000000000000
-p = 0011111111110000000000000000000000000000000000000000000000000001
-
+
1 = 0011111111110000000000000000000000000000000000000000000000000000 +
p = 0011111111110000000000000000000000000000000000000000000000000001

p1 よりも一つ分だけ大きいのがわかるだろうか (ここでは binary64 の具体的な表現について言及していないのでそうなる保証はないのだが、あくまで雰囲気として)。 @@ -183,39 +182,37 @@ p = 0011111111110000000000000000000000000000000000000000000000000001 binary64 を 64 bit の整数に変換できるなら、他の言語でもほとんど同じ方法で実装できるはずだ。

-
    public static function nextUp(float $x): float
-    {
-        // NaN (Not a Number) なら NaN を返す。
-        if (is_nan($x)) {
-            return NAN;
-        }
-        // 正の無限大なら正の無限大を返す。
-        if (is_infinite($x) && $x > 0) {
-            return INF;
-        }
-        // 0 なら minValue() を返す (後述)。
-        if ($x === 0.0) {
-            return self::minValue();
-        }
-        // binary64 を 64 bit 整数に変換する。
-        $u = self::floatToInt($x);
-        // 正なら整数に +1 して binary64 に戻す。
-        // 負なら整数に -1 して binary64 に戻す。
-        return $x > 0.0 ? self::intToFloat($u + 1) : self::intToFloat($u - 1);
-    }
-
+
public static function nextUp(float $x): float +
{ +
// NaN (Not a Number) なら NaN を返す。 +
if (is_nan($x)) { +
return NAN; +
} +
// 正の無限大なら正の無限大を返す。 +
if (is_infinite($x) && $x > 0) { +
return INF; +
} +
// 0 なら minValue() を返す (後述)。 +
if ($x === 0.0) { +
return self::minValue(); +
} +
// binary64 を 64 bit 整数に変換する。 +
$u = self::floatToInt($x); +
// 正なら整数に +1 して binary64 に戻す。 +
// 負なら整数に -1 して binary64 に戻す。 +
return $x > 0.0 ? self::intToFloat($u + 1) : self::intToFloat($u - 1); +
}

0 のときに返している minValue() は次のような値である。

-
    public static function minValue(): float
-    {
-        // 整数の 1 を binary64 と解釈した値を返す。
-        // binary64 で表せる最小の正の非正規化数。
-        return self::intToFloat(1);
-    }
-
+
public static function minValue(): float +
{ +
// 整数の 1 を binary64 と解釈した値を返す。 +
// binary64 で表せる最小の正の非正規化数。 +
return self::intToFloat(1); +
}
-- cgit v1.3-1-g0d28