ときどきの雑記帖 RE* (新南口)
The Catcher in the Rye
TRAIN TV
JR東車内のディスプレイで流れる映像がTRAIN TVなるものになったようなのだけど、 これまで結構楽しみにしていたマルチリンガルなニュースがなくなって悲しい。
- “電車の中のテレビ局”「TRAIN TV」 本日から放映開始 ~4月1日(月)よりJR東日本の13路線・36駅 約65,000の広告面で開局プロモーションを展開~ | 株式会社ジェイアール東日本企画のプレスリリース
- jekiが手がける電車内テレビ局「TRAIN TV」 その狙いと展望とは? | AdverTimes.(アドタイ) by 宣伝会議
- TRAIN TV | 電車の中のテレビ局、はじまる。
番組の内容については触れない(謎)
オーサグラフ
何の気なしに見ていたEテレの番組で知った。
横浜ガンダム
横浜ガンダム、もう少しやればいいのにって思ったけど、最終日前日に金属音を鳴らしながら停止して公開中止になった話を聞いたので(最終日には復活)、かなり「疲労」してたんだろうな
— ぱらみり(青い鳥解放戦線) (@paramilipic) April 1, 2024
よく考えたら連日の稼働って前線でもやらない過酷な運用。ある意味でモビルスーツ運用の限界を検証する施設
そういや期間中はほぼ毎日営業してたのだっけ? いや、緊急事態宣言とかあったか… 海沿いだから塩害もあるだろうしねえ
10 Years of Hacker News
こうして10年分の変化を眺めると
- 10 Years of Hacker News “Ask HN: Who is hiring” Trends : r/programming
- 10 Years of Hacker News “Ask HN: Who is hiring” Trends
新刊近刊
改訂新版 前処理大全
改訂新版 前処理大全~SQL/pandas/Polars実践テクニック
クラウドデータレイク
クラウドデータレイク ―無限の可能性があるデータを無駄なく活かすアーキテクチャ設計ガイド
xz
色々盛り上がってますが。
tnozakiさんならどんなコメントしただろうか などと考えてみたり。
xzのレポート読んだ 色々と条件あるけど、むしろここまでやってるってことは完全に狙い撃ちしてるやつだなあ… あとglibcのIFUNCの話と、lddを信頼できないバイナリに実行してはならない(実際に実行することで依存関係を洗い出す場合がある)ということを知った
— 🌸桜花🌸 (@rofi) March 30, 2024
xz のバックドア、これは痺れるね…
— Kinuko Yasuda (@kinu) March 31, 2024
攻撃者は zstd や lz4 もフォークしてて、どれが次でもおかしくなかった。OSS界は疲弊しており、技術力のある献身的な貢献者を歓迎しないと持続できない。根本のリスクはそこ。ifuncのリゾルバからフックし、特定条下で性能差を観測できるhttps://t.co/swv2GCfMkg
glibcのIFUNCってなんだっけ? な状態なので調べた。
glibc ifunc
- GNU_IFUNC - glibc wiki
- GNU_IFUNCとは何か - a_kawashiroのブログ
- GNU Indirect Function and x86 ELF ABIs | jasoncc.github.io
なるほど
不当に幸運に恵まれた
問題を発見した、MSエンジニアのAndresFreundさんのコメント。
— Shirouzu Hiroaki(白水啓章) (@shirouzu) April 1, 2024
(幸運=別件でのフレームポインタ最適化OFF=valgrindが警告を出したことや Debian unstable利用等)
----
「私たちはここで不当に幸運に恵まれたのであり、今後もそれに頼ることはできないということです」https://t.co/eVLoKO6mWT
「不当に幸運」という表現が引っ掛かったので(ry
AndresFreundTec: “Just to be clear: I didn’t mea…” - Mastodon
Just to be clear: I didn’t mean that I didn’t do good - I did. I mean that we got unreasonably lucky here, and that we can’t just bank on that going forward.
ふむ。unreasonably lucky をどう訳すかということなんだろうけど
うーむ、どれもしっくりくる日本語にできそうにない気が
メモ
https://t.co/0qHq7TCG1q
— がちゃぴん先生 (@gachacomplete) April 1, 2024
すごい詳しくまとまっている。たぶんかなり時間かけたんだろうな。尊敬する
Russ Cox 氏による xz の件の時系列まとめ。
— mattn (@mattn_jp) April 3, 2024
“research!rsc: Timeline of the xz open source attack” https://t.co/hpQXPvD1Ry
新山祐介 (Yusuke Shinyama): “昨日発見されたxz-utilsバックドアの仕組み解説。バック…” - Mastodon 🐘
BgiDecimal
つづき。
BigDecimal.setScaleのRoundingMode.UPがこんなに切り上がるわけがない #初心者 - Qiita
ちょっと気になったので調べてみた。
GNU classpathのコードが比較的わかりやすい気がしたので紹介。
GNU classpath
まずはsetScale
BigDecimal setScale
public BigDecimal setScale (int scale) throws ArithmeticException
{
return setScale (scale, ROUND_UNNECESSARY);
}
public BigDecimal setScale (int scale, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
// NOTE: The 1.5 JRE doesn't throw this, ones prior to it do and
// the spec says it should. Nevertheless, if 1.6 doesn't fix this
// we should consider removing it.
if( scale < 0 ) throw new ArithmeticException("Scale parameter < 0.");
return divide (ONE, scale, roundingMode);
}
/**
* Returns a BigDecimal whose value is the same as this BigDecimal but whose
* representation has a scale of <code>newScale</code>. If the scale is
* reduced then rounding may occur, according to the RoundingMode.
* @param newScale
* @param roundingMode
* @return a BigDecimal whose scale is as given, whose value is
* <code>this</code> with possible rounding
* @throws ArithmeticException if the rounding mode is UNNECESSARY but
* rounding is required
* @since 1.5
*/
public BigDecimal setScale(int newScale, RoundingMode roundingMode)
{
return setScale(newScale, roundingMode.ordinal());
}
結局のところdivide (ONE, scale, roundingMode)
となるので、そのdivideを見ると
BigDecimal divide
public BigDecimal divide (BigDecimal val, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
return divide (val, scale, roundingMode);
}
/**
* Returns a BigDecimal whose value is (this / val), with the specified scale
* and rounding according to the RoundingMode
* @param val the divisor
* @param scale the scale of the BigDecimal returned
* @param roundingMode the rounding mode to use
* @return a BigDecimal whose value is approximately (this / val)
* @throws ArithmeticException if divisor is zero or the rounding mode is
* UNNECESSARY but the specified scale cannot represent the value exactly
* @since 1.5
*/
public BigDecimal divide(BigDecimal val,
int scale, RoundingMode roundingMode)
{
return divide (val, scale, roundingMode.ordinal());
}
/**
* Returns a BigDecimal whose value is (this / val) rounded according to the
* RoundingMode
* @param val the divisor
* @param roundingMode the rounding mode to use
* @return a BigDecimal whose value is approximately (this / val)
* @throws ArithmeticException if divisor is zero or the rounding mode is
* UNNECESSARY but the specified scale cannot represent the value exactly
*/
public BigDecimal divide (BigDecimal val, RoundingMode roundingMode)
{
return divide (val, scale, roundingMode.ordinal());
}
public BigDecimal divide(BigDecimal val, int newScale, int roundingMode)
throws ArithmeticException, IllegalArgumentException
{
if (roundingMode < 0 || roundingMode > 7)
throw
new IllegalArgumentException("illegal rounding mode: " + roundingMode);
if (intVal.signum () == 0) // handle special case of 0.0/0.0
return newScale == 0 ? ZERO : new BigDecimal (ZERO.intVal, newScale);
// Ensure that pow gets a non-negative value.
BigInteger valIntVal = val.intVal;
int power = newScale - (scale - val.scale);
if (power < 0)
{
// Effectively increase the scale of val to avoid an
// ArithmeticException for a negative power.
valIntVal = valIntVal.multiply (BigInteger.TEN.pow (-power));
power = 0;
}
BigInteger dividend = intVal.multiply (BigInteger.TEN.pow (power));
BigInteger parts[] = dividend.divideAndRemainder (valIntVal);
BigInteger unrounded = parts[0];
if (parts[1].signum () == 0) // no remainder, no rounding necessary
return new BigDecimal (unrounded, newScale);
if (roundingMode == ROUND_UNNECESSARY)
throw new ArithmeticException ("Rounding necessary");
int sign = intVal.signum () * valIntVal.signum ();
if (roundingMode == ROUND_CEILING)
roundingMode = (sign > 0) ? ROUND_UP : ROUND_DOWN;
else if (roundingMode == ROUND_FLOOR)
roundingMode = (sign < 0) ? ROUND_UP : ROUND_DOWN;
else
{
// half is -1 if remainder*2 < positive intValue (*power), 0 if equal,
// 1 if >. This implies that the remainder to round is less than,
// equal to, or greater than half way to the next digit.
BigInteger posRemainder
= parts[1].signum () < 0 ? parts[1].negate() : parts[1];
valIntVal = valIntVal.signum () < 0 ? valIntVal.negate () : valIntVal;
int half = posRemainder.shiftLeft(1).compareTo(valIntVal);
switch(roundingMode)
{
case ROUND_HALF_UP:
roundingMode = (half < 0) ? ROUND_DOWN : ROUND_UP;
break;
case ROUND_HALF_DOWN:
roundingMode = (half > 0) ? ROUND_UP : ROUND_DOWN;
break;
case ROUND_HALF_EVEN:
if (half < 0)
roundingMode = ROUND_DOWN;
else if (half > 0)
roundingMode = ROUND_UP;
else if (unrounded.testBit(0)) // odd, then ROUND_HALF_UP
roundingMode = ROUND_UP;
else // even, ROUND_HALF_DOWN
roundingMode = ROUND_DOWN;
break;
}
}
if (roundingMode == ROUND_UP)
unrounded = unrounded.add (BigInteger.valueOf (sign > 0 ? 1 : -1));
// roundingMode == ROUND_DOWN
return new BigDecimal (unrounded, newScale);
}
/**
* Performs division, if the resulting quotient requires rounding
* (has a nonterminating decimal expansion),
* an ArithmeticException is thrown.
* #see divide(BigDecimal, int, int)
* @since 1.5
*/
public BigDecimal divide(BigDecimal divisor)
throws ArithmeticException, IllegalArgumentException
{
return divide(divisor, scale, ROUND_UNNECESSARY);
}
BigInteger parts[] = dividend.divideAndRemainder (valIntVal);
BigInteger unrounded = parts[0];
if (parts[1].signum () == 0) // no remainder, no rounding necessary
return new BigDecimal (unrounded, newScale);
で、ずっと下の方の桁であっても剰余があれば 丸めを行っていて、Scale付近の桁を特にみていたりはしていない。
decimal — 十進固定及び浮動小数点数の算術演算 — Python 3.12.2 ドキュメント
quantize() メソッドは位を固定して数値を丸めます。このメソッドは、結果を固定の桁数で丸めることがよくある、金融アプリケーションで便利です:
Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN) Decimal('7.32') Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP) Decimal('8')
quantize(exp, rounding=None, context=None)
二つ目の操作対象と同じ指数を持つように丸めを行った、一つめの操作対象と等しい値を返します。
BigDecimal#round (Ruby 3.3 リファレンスマニュアル)
Math::BigFloat - arbitrary size floating point math package - Perldoc Browser
Rounding
bfround ( +$scale )
Rounds to the $scale’th place left from the ‘.’, counting from the dot. The first digit is numbered 1.
awk
第2版
結構伸びている?
[B! awk] 35年ぶりの第2版「プログラミング言語AWK 第2版」、オライリーから5月発売
An Awk Implementation in C99
オリジナルのawk処理系作りました。という話題。
- An Awk Implementation in C99 | Hacker News
- An Awk Implementation in C99 : r/programming
- An awk implementation | A somewhat compact implementation of the awk programming language
- GitHub - raygard/wak: wak – an awk implementation for toybox and standalone
FORTRAN Compiler on IBM 704
STATEC
作業領域BETA
をちょっと追っかけ(その2)
使いまわししている? >RECLEAR BETA TABLE
AS0000 LXA L(0),7 RENUMBER SEGMENT OF SCRIPL 4F14488
*
AS0100 CLA BETA,B 4F14489
TZE AS0700 4F14490
PXD 0,C 4F14491
ARS 18 4F14492
STA BETA,B 4F14493
TXI AS0700,C,-1 4F14494
AS0700 TXI AS0800,B,-1 4F14495
AS0800 TXH AS0100,B,0 4F14496
*
*
AS0900 CLA SCRIPL,A 4F14497
PAX 0,B 4F14498
CLA BETA,B 4F14499
STA SCRIPL,A 4F14500
LDQ SCRIPL+2,A 4F14501
LGL 1 4F14502
LBT 4F14503
TQP AS2000 4F14504
TXI AS1800,A,-3 4F14505
AS1800 TXH AS0900,A,0 4F14506
TRA AS2500 4F14507
*
AS2000 LGL 35 4F14508
PAX 0,B 4F14509
CLA BETA,B 4F14510
STA SCRIPL+2,A 4F14511
TXI AS1800,A,-3 4F14512
*
AS2500 LXA L(0),3 LDXA,XB WITH 0 4F14513
LDQ L(0) CLEAR MQ 4F14514
*
AS2700 STO BETA,B RECLEAR BETA TABLE 4F14515
TXI AS2900,B,-1 4F14516
AS2900 TXH AS2700,B,0 4F14517
*
*
AS3000 CLA SCRIPL,A ADD INTO GAMMA COUNTERS 4F14518
PAX 0,B 4F14519
CLA BETA,B 4F14520
ADD BETAD2 3*2**18+(-3) 4F14521 BETAD2 OCT 3077775
STD BETA,B 4F14522
STA BETA,B 4F14523
TXI AS3600,A,-3 4F14524
AS3600 TXH AS3000,A,0 -30 IN XA AT END 4F14525
*
SXD 3QBAR,A -30 TO 3QBAR = 3LBAR 4F14526
*
CCS000 CAL SCRIPL-3,A ELIMINATE COMMON SUBEXPRESSIONS 4F14527
BETAD2
BETAD2 OCT 3077775
0 3 18 21 35
+---+---------------+---+---------------+
|000|000000000000011|000|111111111111101|
+---+---------------+---+---------------+
プログラミング言語処理系の講義で寄せられた質問への回答を毎週書いて履修者に公開していたのだが,それが結構な量になったので公開することにした.なにか気づいたことがあったら issue とか PR とかで知らせてほしいなあ.https://t.co/38FwzYnK4a
— Kohei Suenaga (@ksuenaga) April 1, 2024
OSIのいうオープンソース、GNUのような社会的な自由でなく、個々人が束縛されないという意味での自由を目指しているという意味でどちらかというとリバタニアリズムよりじゃね(´・ω・`)
— てらモス🌻 (@termoshtt) April 1, 2024
オープンソースって用語、ライセンスの話と、その周辺のムーブメントの話と、両方が乗っていて分かりづらい部分も、まああると思う…
— Ryusei (@mandel59) April 1, 2024
ライセンスの追加 · Issue #2 · IchigoJam/ichigojam-firm