ときどきの雑記帖 RE* (新南口)
The Return of ISHTAR
パナソ
パナソニックをパナソと略する人を目撃
WL
1/700てことはウォーターラインシリーズだろうか 懐かしいなあと思いつつ値段見てひっくり返りそうになった。
フジミ模型、プラモデル「1/700 特99 日本海軍重巡洋艦 伊吹」本日より出荷開始! - HOBBY Watch
フジミ模型は、プラモデル「1/700 特99 日本海軍重巡洋艦 伊吹」を10月27日に出荷開始する。価格は5,060円。
自分がよく作ってた頃の値段と文字通り一桁違いますがな。
1992年にフジミ模型が静岡模型教材協同組合から脱退し、自社担当分のキットもウォーターラインから引き揚げてシーウェイモデルシリーズという名称に変更した。
なんと。
Hawk
[B! 生物] 鴨川でトビに食べ物さらわれるの なんでなん? | NHK
片瀬江ノ島とか由比ヶ浜、材木座海岸なんかは 「鳶(英語表記はHawk)に注意」とか看板出てますよね。
あと材木座海岸でハンバーガーさらわれたこともある。
鎌倉民からすると、当たり前やん。疑問を持つ方が不思議だ
私は江の島(片瀬西浜海岸というのかな)でトビにハンバーガーを取られそうになったことがある😅同じようなことなのだろうか?
ノイキャン
- [B!] 【特集】 ソニー「WF-1000XM5」のノイキャンはマジでほとんど聞こえなくなる。家・電車・街中・喫茶店で捗り具合を徹底検証
- 【特集】ソニー「WF-1000XM5」のノイキャンはマジでほとんど聞こえなくなる。家・電車・街中・喫茶店で捗り具合を徹底検証 - PC Watch
試してみたいが以下略
R
その後。
とりあえず4.2.xもインストールして試してみるか (以前のPCはもうないので直接比較はできないけど 動いた実績はあるわけで)。
と書いたことを試してみたら
R version 4.2.1 (2022-06-23 ucrt) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
> curlGetHeaders("https://google.com/")
curlGetHeaders("https://google.com/") でエラー: libcurl error code 4:
Unsupported proxy 'https://xxxxxxxx', libcurl is built without the HTTPS-proxy support.
こうなった。
何故?
ちなみに4.3.1だと
R version 4.3.1 (2023-06-16 ucrt) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
> curlGetHeaders("https://google.com/")
curlGetHeaders("https://google.com/") でエラー: libcurl error code 28:
Connection timed out after 60014 milliseconds
こうなる(エラーコードが違う)。
どうしようかと思いつつ
libcurl error code 28
で検索してみるとこんな記事が見つかった。
その中に
libcurl is built without the https-proxy support となってネットワークにつながらないときの解決策 - ひつじTips
HTTPS_PROXY=http://<proxy-host>:<proxy-port>
と http すると上手くいく 意味がわからん..
というのがあったのでこれを試したら…繋がった。
なにがなにやら🤔
検索で見つかったものに似たような現象の報告があったり
- libcurl - Error Codes
- libcurl is built without the HTTPS-proxy support ・ Issue #186 ・ jeroen/curl ・ GitHub
そしてhttps_proxyに設定するURLをhttpにするかhttpsにするかで 動作が変わるのは確からしい。
https_proxy=httpとhttps_proxy=httpsは何が違うのか? #curl - Qiita
よくわからんが動くようになったからヨシ!
x^y
JavaScriptなどのべき乗演算はNaNが戻ることがある
この記事を読んで、なるほどと思いながらも 呼び出しているであろうCライブラリのpowだとどうなんだろうか というのが気になったので(ry
以下のエラーが発生する可能性がある。
領域エラー: x が負で、y が整数でない有限値
errno に EDOM が設定される。 不正 (invalid) 浮動小数点例外 (FE_INVALID) が上がる。
Function: double pow (double base, double power)
Function: float powf (float base, float power)
Function: long double powl (long double base, long double power)
Function: _FloatN powfN (_FloatN base, _FloatN power)
Function: _FloatNx powfNx (_FloatNx base, _FloatNx power)
These are general exponentiation functions, returning base raised to power.
Mathematically, pow would return a complex number when base is negative and power is not an integral value. pow can’t do that, so instead it signals a domain error. pow may also underflow or overflow the destination type.
ふむ。とするとこのエラーを拾ってごにょごにょしているんだろうか。
記事中言及のあったPythonの動作についても ドキュメントに当たってみた(なぜこれをしないのだろう?)
Math.powと組込みのpowとで別々に記述があった。 微妙に動作が異なる点があるらしい。
math — Mathematical functions — Python 3.12.0 documentation
math.pow(x, y)
Return x raised to the power y. Exceptional cases follow the IEEE 754 standard as far as possible. In particular, pow(1.0, x) and pow(x, 0.0) always return 1.0, even when x is a zero or a NaN. If both x and y are finite, x is negative, and y is not an integer then pow(x, y) is undefined, and raises ValueError.
Unlike the built-in ** operator, math.pow() converts both its arguments to type float. Use ** or the built-in pow() function for computing exact integer powers.
Changed in version 3.11: The special cases pow(0.0, -inf) and pow(-0.0, -inf) were changed to return inf instead of raising ValueError, for consistency with IEEE 754.
Built-in Functions — Python 3.12.0 documentation
pow(base, exp, mod=None)
Return base to the power exp; if mod is present, return base to the power exp, modulo mod (computed more efficiently than pow(base, exp) % mod). The two-argument form pow(base, exp) is equivalent to using the power operator: base**exp.
The arguments must have numeric types. With mixed operand types, the coercion rules for binary arithmetic operators apply. For int operands, the result has the same type as the operands (after coercion) unless the second argument is negative; in that case, all arguments are converted to float and a float result is delivered. For example, pow(10, 2) returns 100, but pow(10, -2) returns 0.01. For a negative base of type int or float and a non-integral exponent, a complex result is delivered. For example, pow(-9, 0.5) returns a value close to 3j.
C:\Users\kbk>python
Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> pow(-2,0.5)
(8.659560562354934e-17+1.4142135623730951j)
>>> import math
>>> math.pow(-2,0.5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: math domain error
>>>
なるほど。
演算子(**
)でも記述があった。
6. Expressions — Python 3.12.0 documentation
6.5. The power operator
The power operator binds more tightly than unary operators on its left; it binds less tightly than unary operators on its right. The syntax is:
power ::= (await_expr | primary) ["**" u_expr]
Thus, in an unparenthesized sequence of power and unary operators, the operators are evaluated from right to left (this does not constrain the evaluation order for the operands): -1**2 results in -1.
The power operator has the same semantics as the built-in pow() function, when called with two arguments: it yields its left argument raised to the power of its right argument. The numeric arguments are first converted to a common type, and the result is of that type.
For int operands, the result has the same type as the operands unless the second argument is negative; in that case, all arguments are converted to float and a float result is delivered. For example, 10**2 returns 100, but 10**-2 returns 0.01.
Raising 0.0 to a negative power results in a ZeroDivisionError. Raising a negative number to a fractional power results in a complex number. (In earlier versions it raised a ValueError.)
This operation can be customized using the special __pow__() method.
>>> -2**0.5
-1.4142135623730951
>>> (-2)**0.5
(8.659560562354934e-17+1.4142135623730951j)
ふむ。
ついでにRubyも見ておこう
class Integer (Ruby 3.2 リファレンスマニュアル)
self ** other -> Numeric
pow(other) -> Numeric
pow(other, modulo) -> Integer
戻り値の型がNumericだったり、 エラーになるなどの具体的な説明は見当たらなかったので じゃあと試してみると
irb(main):001:0> RUBY_VERSION
=> "3.1.2"
irb(main):002:0>-2**3
=> -8
irb(main):003:0>-2**0.5
=> -1.41421356237
irb(main):004:0>(-2)**0.5
=> (0.0+1.4142135623730951i)
なるほど。
おまけでJava。
- 最初の引数が有限でゼロより小さい場合
- 2番目の引数が有限の偶数の整数の場合、結果は最初の引数の絶対値を2番目の引数で累乗した値に等しくなります
- 2番目の引数が有限の奇数の整数の場合、結果は最初の引数の絶対値を2番目の引数で累乗した値の負の値に等しくなります
- 2番目の引数が有限であり、かつ整数ではない場合、結果はNaNになります。
とすると、Math.pow(-2, 0.5)は最後の条件に当てはまるので その結果はNaNだということですね。
awk
gawk
5.3.0もいよいよ? で、ちょっと気になるバグレポなどがあったのでメモ。
- Beta relase of gawk 5.3.0
- This note is to announce the BETA release of GNU Awk 5.3.0.
- Re: gensub crash
- Re: Gawk manual section: 8.6 Arrays of Arrays
関係するコミットはこの辺ですか
Fix a use-after-free error for gensub.
diff --git a/builtin.c b/builtin.c
index 88663eb..ba3459d 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3330,8 +3330,9 @@ done:
return make_str_node(buf, textlen, ALREADY_MALLOCED);
} else if ((target->flags & STRING) == 0) {
/* return a copy of original string */
+ NODE *copy = make_str_node(target->stptr, target->stlen, 0);
DEREF(target);
- return make_str_node(target->stptr, target->stlen, 0);
+ return copy;
}
/* return the original string */
Fix a potential use-after-free error
diff --git a/eval.c b/eval.c
index b46e3aa..6bc39de 100644
--- a/eval.c
+++ b/eval.c
@@ -1317,8 +1317,11 @@ setup_frame(INSTRUCTION *pc)
/* $0 needs to be passed by value to a function */
if (m == fields_arr[0]) {
+ NODE *copy;
+
+ copy = dupnode(m); // will be real copy
DEREF(m);
- m = dupnode(m);
+ m = copy;
}
switch (m->type) {
なるほどuse after free。
ところでこのDEREF、かなり以前から存在しているものなんだけど バージョンによって違いがあった。
5.2.2
static inline void
DEREF(NODE *r)
{
assert(r->valref > 0);
#ifndef GAWKDEBUG
if (--r->valref > 0)
return;
#endif
r_unref(r);
}
4.1.0
static inline void
DEREF(NODE *r)
{
if (--r->valref == 0)
r_unref(r);
}
4.0.2以前だとマクロで定義されている
/*
* UPREF and DEREF --- simplified versions of dupnode and unref
* UPREF does not handle FIELD node. Most appropriate use is
* for elements on the runtime stack. When in doubt, use dupnode.
*/
#define DEREF(r) ( _r = (r), (!(_r->flags & PERM) && (--_r->valref == 0)) ? unref(_r) : (void)0 )
3.1.8以前だとDEREFはない。が、↑のDEREFマクロで使っているunref関数はある。
extern void unref P((NODE *tmp)); //node.c
Add zh_CN.po
中文のメッセージデータを眺めて 中国語ではこれはこう表現するのか といった諸々を知るなど。
FORTRAN Compiler on IBM 704
STATE C 手ごわい。
新刊近刊
ギリシア人の物語 文庫版第3巻
予想通り単行本の3巻めが2分冊になるようだ。 文庫第3巻の厚さからすると、分冊しないでも問題なさそうだけど 一冊の値段を考えてのことかもしれない。 たしかローマ人の物語の文庫化の際に そういったことについての発言があったように記憶している。
地図は意外とウソつき
2023/10/29の日記 - 地図は意外とウソつき読了 - TAROLIN / 冬のはじまる日 - smellman’s Broken Diary
なにやら面白そうな本。
出版社 : 河出書房新社 (2023/10/25)
出たばかりの模様。
ライブラリ データ科学他
新刊でも近刊でもないけどメモ。
ライブラリ データ科学 – 株式会社サイエンス社 株式会社新世社 株式会社数理工学社
共立出版のシリーズ本
《続刊テーマ》 -『紙と計算機による数学入門』 -『紙と数学による計算機入門』 -『Proof Checker活用法』 -『JavaScriptによる数式処理』
続刊はまだかしらん。
こんなのがあったんだ。 だいぶ前の本だからジュンク堂くらいにしかないかな?
実践プロパティベーステスト
というわけで、新刊です。しかも、プロパティベーステストだけが徹底的に解説された本の翻訳です。メインはErlangだけど原則として全コードにElixir版も併記されてるから、Erlangのコードさっぱりわからんという人はそれで雰囲気をつかんでほしいです! https://t.co/DfFmsqejJN
— 専門性・売上・原稿 (@golden_lucky) October 30, 2023
逃れがたいもの
C++からも逃げられないらしい
人類、C++から逃れられない
— 電子計算機の沼 (@Hishinuma_t) October 30, 2023
文字列
lwnの元記事がまだSubscription requiredで読めないので詳細がわからないのだけど、 この手の提案や「ライブラリ作りました」のようなものは はこれまでもHNやredditでいくつか出ていたわけで それらとは違う何かがあるんだろうか。
まあLinuxカーネルで使おう(使う)と言うのであれば かなりの違いと言えるか。
そうまでしてCなのか という思いと やっぱりCにせざるを得ないよなぁ という思いが交錯する https://t.co/XsuLDXpOSk
— yoh (@yohhoy) October 28, 2023