何処に書き込むか迷いましたが、ここに。
DWordNum1 = 10 ^ DWordNum2
上記の様な指数演算にて、
[警告] DoubleからDWordに強制変換されています。データが失われる可能性があります。
と出ますが、DWord 型 とリテラル値のみの演算で上記の様な警告が出るのは、そういうものなのですか。内部の演算が Double 型で扱われている様な話は聞いていますが、プログラマーから見た場合、明らかに DWord 型 の演算なのに警告が出るのはチョット変な気がします。恐らく、DWord 型 のレベルで失われるデータは、&hFFFFFFFF を超えた場合、0 を下回った場合以外は無いのではと思います。その点に関しては、DWord 型 とリテラル値の加減算でも同じで、そちらは警告が出ませんよね。
バグではなく、警告としなければ為らない理由が在るのでしたら、教えて頂けますか。
指数演算の警告
確かbasic/function.sbp内の関数powの仕様の関係でDouble型を返すことになってたはずです。(コンパイラ側の仕様で必ず内包される関数のひとつの筈。)
グローバル領域でのオーバーロードができれば対処できるかもしれません。
どちらにしても4.24だと無理だった気がするんですが。
具体的には
直接書き換えるとDouble型の演算がうまくいかなくなると思うのでやめておいてください。
#Fixとかは組み込むのにこいつを組み込まないのはどうしてなんでしょうねぇ・・・。
グローバル領域でのオーバーロードができれば対処できるかもしれません。
どちらにしても4.24だと無理だった気がするんですが。
具体的には
こんな奴 [ここをクリックすると内容が表示されます]
を定義(オーバーロード)する必要があるわけです。コード: 全て選択
Function pow(x As Long, n As DWord) As Long
Dim r As Long
r=1
While n
If n and 1 Then r=r*x
x=x*x
n=n>>1
Wend
pow=r
End Function直接書き換えるとDouble型の演算がうまくいかなくなると思うのでやめておいてください。
#Fixとかは組み込むのにこいつを組み込まないのはどうしてなんでしょうねぇ・・・。
追記:山本さんが機械語を読まないのを思い出したので、組み込み用のバイナリとか作ってみました。 [ここをクリックすると内容が表示されます]
どうみても暇なだけです。
55 8B EC 53 56 8B 4D 0C B8 01 00 00 00 8B 5D 08
F7 C1 01 00 00 00 74 02 F7 EB 8B F0 8B C3 F7 E8
8B D8 8B C6 D1 E9 75 E8 5E 5B C9 C2 08 00
(46byte,呼び出し:stdcall,引数:上のコードと同一)
55 8B EC 53 56 8B 4D 0C B8 01 00 00 00 8B 5D 08
F7 C1 01 00 00 00 74 02 F7 EB 8B F0 8B C3 F7 E8
8B D8 8B C6 D1 E9 75 E8 5E 5B C9 C2 08 00
(46byte,呼び出し:stdcall,引数:上のコードと同一)
source code [ここをクリックすると内容が表示されます]
コード: 全て選択
pow proc x:dword,n:dword
push ebx
push esi
;ret=r=eax
;n=ecx
;x=ebx
mov ecx,n
mov eax,1
mov ebx,x
_l1:
test ecx,1
jz _l2
imul ebx
_l2:
mov esi,eax
mov eax,ebx
imul eax
mov ebx,eax
mov eax,esi
shr ecx,1
jnz _l1
pop esi
pop ebx
ret
pow endpWebsite→http://web1.nazca.co.jp/himajinn13sei/top.html
ここ以外の場所では「暇人13世」というHNを主として使用。
に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。
ここ以外の場所では「暇人13世」というHNを主として使用。
に署名を書き換えて欲しいと言われたので暇だしやってみるテスト。
-
彦左衛門
Re: 指数演算の警告
My name is Anton, and my battleground is a checkered board of sixty-four squares. I teach chess to children and teenagers at a community center. My days are filled with the soft clack of pieces, whispered strategies, and the bright, sometimes frustrated, eyes of kids learning patience and foresight. I love the purity of it. Every move has a consequence. Every game is a story of cause and effect. But my world, for all its intellectual richness, is financially sparse. The center pays a modest stipend, and private lessons are a luxury few parents in our neighborhood can afford. My own apartment is a small, quiet place, its most prominent feature a bookshelf sagging with chess theory. My dream is to take my top students to a national youth tournament. The travel, hotels, entry fees—it’s a sum that feels as distant as grandmaster title.
The silence after the last student leaves is heavy. Not with peace, but with the echo of unmade moves, of potential I can’t afford to unlock. I’d set up my own board, analyze famous games, but my mind would wander to budgets and logistics, a mundane endgame I couldn’t solve.
The change came from the father of my most promising student, Misha. He was a logistics manager, a man who understood complex systems. He’d often stay to watch the lessons, fascinated. One evening, as we waited for Misha to finish a timed puzzle, he sighed. “All this calculation. My brain is tired of optimal routes and efficiency charts.” He pulled out his phone. “I need a system where the optimal move is to let go.” He showed me a site. “This is my reset. It’s on the vavada ua domain. Straightforward. Sometimes you just have to make a move and see what the universe responds with.”
Vavada ua. The Ukrainian domain. It felt specific, rooted somewhere. Not a nebulous .com, but a place. In my world of defined coordinates, this appealed to me. That night, after reviewing Misha’s brilliant sacrifice in a puzzle, I was too mentally alert to sleep. I typed it in. The vavada ua site was clean, no-nonsense. I registered as “KnightMove.” I deposited the cost of a new tournament chess clock—a professional expense, I reasoned. This was a study in anti-chess, a lesson in embracing chaos.
I didn’t touch the card games. I went straight to a game called “Checkmate Cash.” It was a slot, but the theme was a whimsical, animated chessboard. The symbols were cartoon kings, queens, knights, and pawns. The sound of capturing a piece was a satisfying thump. I set a tiny bet. I hit spin. The reels, designed like chess files (a-h), spun. It was silly, but charming. For twenty minutes after my last lesson, I’d play. It was the opposite of teaching. There was no strategy to impart, no mistake to correct. The vavada ua site was my mental sandbox where the only rule was randomness. The focus required to follow the game’s whims actually helped quiet the anxious planning part of my brain.
It became a ritual. A palate cleanser. I’d analyze a student’s disastrous opening, then I’d spin the cartoon chess reels, watching luck make its own, consequence-free “moves.”
The crisis was both bureaucratic and personal. The community center’s funding was cut. My stipend was halved, effective immediately. At the same time, Misha qualified for the national tournament. The look on his face—pure, unadulterated hope—crushed me even as it filled me with pride. I knew his family couldn’t afford it. I couldn’t afford to sponsor him. The right move, the moral move, was clear. But I lacked the material to make it.
That night, the silence in my apartment was suffocating. I felt like a king in check with no squares to run to. I logged into vavada ua, not for escape, but as a final, frivolous gesture before conceding defeat. I had a small bonus from a daily login. I went to Checkmate Cash. I set a bet, not my usual tiny one, but a meaningful chunk of my remaining entertainment budget. A desperate, unsound sacrifice.
One spin.
The cartoon pieces tumbled. They settled. Three “Golden Knight” symbols, their horses gleaming.
The screen didn’t just flash; it reconfigured. A bonus round, “Grandmaster’s Gambit,” initiated. I was shown a chessboard in a middle-game position. I wasn’t asked to solve it. I was asked to choose a piece to move for white. It was a completely random choice—no hint of the best move. I chose the queen’s knight, my favorite piece.
The knight moved. The board reacted. A path lit up, showing a sequence of captures. Each captured piece transformed into a multiplier: a pawn (2x), a bishop (5x), the opponent’s queen (10x). The sequence ended with a flashing “CHECKMATE” graphic, which unlocked a 50x multiplier for the ensuing 25 free spins.
The free spins were a masterclass in compounding advantage. Each win was multiplied by the growing total from the captured pieces, then finally by the 50x checkmate bonus. My desperate bet was the pawn pushed on the first move of a stunning, computer-like combination played by fate itself. The numbers escalated not arithmetically, but exponentially, like a perfectly executed attacking sequence on the board.
When the final spin settled, the total was not just “send Misha to the tournament” money. It was “secure the center’s chess program funding for a year, send Misha and two other deserving kids to the tournament with a proper coach (me), and finally buy that solid wood demonstration board” money.
I stared at the screen. In chess, we call a winning sequence a “forcing line.” This was the most forcing line life had ever presented me. Vavada ua had just delivered the resources to make all the right moves.
The money was real. The center’s director cried when I told her. Misha’s father shook my hand for a full minute, speechless.
Now, the community center’s chess program is thriving. We went to nationals. And sometimes, after a long day of teaching the Sicilian Defense, I’ll log in to that Ukrainian domain. I’ll play a few spins of Checkmate Cash, smiling at the cartoon knights. It’s not a game of chance to me anymore. It’s a monument to a single, perfect sequence. A reminder that even when the position seems hopeless, sometimes you just have to make a move—any move—and trust that the universe might just have a beautiful, forced mate in store.
The silence after the last student leaves is heavy. Not with peace, but with the echo of unmade moves, of potential I can’t afford to unlock. I’d set up my own board, analyze famous games, but my mind would wander to budgets and logistics, a mundane endgame I couldn’t solve.
The change came from the father of my most promising student, Misha. He was a logistics manager, a man who understood complex systems. He’d often stay to watch the lessons, fascinated. One evening, as we waited for Misha to finish a timed puzzle, he sighed. “All this calculation. My brain is tired of optimal routes and efficiency charts.” He pulled out his phone. “I need a system where the optimal move is to let go.” He showed me a site. “This is my reset. It’s on the vavada ua domain. Straightforward. Sometimes you just have to make a move and see what the universe responds with.”
Vavada ua. The Ukrainian domain. It felt specific, rooted somewhere. Not a nebulous .com, but a place. In my world of defined coordinates, this appealed to me. That night, after reviewing Misha’s brilliant sacrifice in a puzzle, I was too mentally alert to sleep. I typed it in. The vavada ua site was clean, no-nonsense. I registered as “KnightMove.” I deposited the cost of a new tournament chess clock—a professional expense, I reasoned. This was a study in anti-chess, a lesson in embracing chaos.
I didn’t touch the card games. I went straight to a game called “Checkmate Cash.” It was a slot, but the theme was a whimsical, animated chessboard. The symbols were cartoon kings, queens, knights, and pawns. The sound of capturing a piece was a satisfying thump. I set a tiny bet. I hit spin. The reels, designed like chess files (a-h), spun. It was silly, but charming. For twenty minutes after my last lesson, I’d play. It was the opposite of teaching. There was no strategy to impart, no mistake to correct. The vavada ua site was my mental sandbox where the only rule was randomness. The focus required to follow the game’s whims actually helped quiet the anxious planning part of my brain.
It became a ritual. A palate cleanser. I’d analyze a student’s disastrous opening, then I’d spin the cartoon chess reels, watching luck make its own, consequence-free “moves.”
The crisis was both bureaucratic and personal. The community center’s funding was cut. My stipend was halved, effective immediately. At the same time, Misha qualified for the national tournament. The look on his face—pure, unadulterated hope—crushed me even as it filled me with pride. I knew his family couldn’t afford it. I couldn’t afford to sponsor him. The right move, the moral move, was clear. But I lacked the material to make it.
That night, the silence in my apartment was suffocating. I felt like a king in check with no squares to run to. I logged into vavada ua, not for escape, but as a final, frivolous gesture before conceding defeat. I had a small bonus from a daily login. I went to Checkmate Cash. I set a bet, not my usual tiny one, but a meaningful chunk of my remaining entertainment budget. A desperate, unsound sacrifice.
One spin.
The cartoon pieces tumbled. They settled. Three “Golden Knight” symbols, their horses gleaming.
The screen didn’t just flash; it reconfigured. A bonus round, “Grandmaster’s Gambit,” initiated. I was shown a chessboard in a middle-game position. I wasn’t asked to solve it. I was asked to choose a piece to move for white. It was a completely random choice—no hint of the best move. I chose the queen’s knight, my favorite piece.
The knight moved. The board reacted. A path lit up, showing a sequence of captures. Each captured piece transformed into a multiplier: a pawn (2x), a bishop (5x), the opponent’s queen (10x). The sequence ended with a flashing “CHECKMATE” graphic, which unlocked a 50x multiplier for the ensuing 25 free spins.
The free spins were a masterclass in compounding advantage. Each win was multiplied by the growing total from the captured pieces, then finally by the 50x checkmate bonus. My desperate bet was the pawn pushed on the first move of a stunning, computer-like combination played by fate itself. The numbers escalated not arithmetically, but exponentially, like a perfectly executed attacking sequence on the board.
When the final spin settled, the total was not just “send Misha to the tournament” money. It was “secure the center’s chess program funding for a year, send Misha and two other deserving kids to the tournament with a proper coach (me), and finally buy that solid wood demonstration board” money.
I stared at the screen. In chess, we call a winning sequence a “forcing line.” This was the most forcing line life had ever presented me. Vavada ua had just delivered the resources to make all the right moves.
The money was real. The center’s director cried when I told her. Misha’s father shook my hand for a full minute, speechless.
Now, the community center’s chess program is thriving. We went to nationals. And sometimes, after a long day of teaching the Sicilian Defense, I’ll log in to that Ukrainian domain. I’ll play a few spins of Checkmate Cash, smiling at the cartoon knights. It’s not a game of chance to me anymore. It’s a monument to a single, perfect sequence. A reminder that even when the position seems hopeless, sometimes you just have to make a move—any move—and trust that the universe might just have a beautiful, forced mate in store.