藤原です。 This message is reply to Sawaguchi Yuji - san (Subject was : [H8-ML(4776)] ReH8/3664 にて日付演算) Message-ID: <40a1666b.9076%issho@xxxxxxxxxxxxxxxxx> in Wed, 12 May 2004 08:48:59 +0900 ... > hamayanさんの<200405112155.i4BLt3o13734@xxxxxxxxxxxxxxxxxxxxx>から > >これも秒桁が20秒増えてしまいますね。 > ポインタで型キャストして '59' を一度に比較する必要が > あります。 > すなわち、pSec で秒桁をポイントしておいて、 > > if (++*pSec > 0x3539) *pSec = 0x3030; 既に、hamayan さんがお書きですが、低い方の桁がいつも同じ条件で 桁上がりするときには、ひと桁ずつのチェックで可能です。 例外は、桁上がりの条件が上の桁によって変わるときで…… > char times[7]; > char limit[7] = "235959"; > int i; > > /* このあたりで初期化 */ > > times[5]++; > for(i = 5; i >= 0; i--) > { > if (times[i] > limit[i]) > { > times[i] = '0'; > /* ここがいやらしい */ > if (i != 0) > times[i - 1]++; > } > } おお、135959 の次が、200000 になってしまいますね。 しっかりバグっている。 -- _/ -- Last 2249 hours until ATHENS 2004 Olympic Games ----------------- _/ FUJIHARA Keiichi _/ E-Mail : keiichi@xxxxxxxxxxxxx <or> nagi@xxxxxxxxxxxxxxx _/ URL : http://www.keiichi.fujihara.name/ ----------------------------------------------+----- Luna Phase 22.76 -- PGP FingerPrint = 7CC3 4F95 8CC7 87D3 7178 C348 CD65 7F08 D68F 69F6