ãã®ä»ã®éšåïŒ
- ããŒã1
- ããŒã2
- ããŒã3
åºæ
Dã§æãäžè¬çã«äœ¿çšãããããŒã«ã¯ã ããã¹ããšãã£ã¿ãŒãšã³ã³ãã€ã©ãŒã§ããããšãå ã«ããããŸãã ã Dã®ããã°ã©ã ã¯ãããã¹ããšãã£ã¿ãŒïŒã䜿ãã®KOïŒã§èšè¿°ãããŠããŸãã
Dãªã©ã®ã³ã³ãã€ã«æžã¿èšèªã䜿çšããå Žåã ã³ã³ãã€ã«ã®æŠå¿µãšã³ã³ãã€ã©ãŒã®æ©èœãç解ããå¿ èŠããããŸãã
ã³ã³ãã¥ãŒã¿ãŒã®é è³ã¯ãã€ã¯ãããã»ããµãŒïŒãŸãã¯CPUã äžå€®åŠçè£ çœ®ã®ç¥ïŒã§ãã ã³ãŒãã£ã³ã°ã¯CPUãäœããã¹ããã瀺ããã®ã§ããã䜿çšãããåœä»€ã¯ãã·ã³ã³ãŒããšåŒã°ããŸã ã
ã»ãšãã©ã®CPUã¢ãŒããã¯ãã£ã¯ããããã«åºæã®ãã·ã³åºæã®ã³ãŒãã䜿çšããŸãã ãããã®ãã·ã³åœä»€ã¯ãã¢ãŒããã¯ãã£èšèšäžã®ããŒããŠã§ã¢å¶éã«ãã£ãŠæ±ºå®ãããŸãã æäœã¬ãã«ã§ã¯ããããã®åœä»€ã¯é»æ°ä¿¡å·ãšããŠå®è£ ãããŸãã ãã®ã¬ãã«ã§ã®ããã°ã©ãã³ã°ã®åçŽãã¯äž»ãªç®æšã§ã¯ãªããããCPUã®ã³ã³ãã¥ãŒã¿ãŒã³ãŒãã«çŽæ¥ããã°ã©ã ãèšè¿°ããããšã¯éåžžã«é£ããã¿ã¹ã¯ã§ãã
ãããã®ãã·ã³åœä»€ã¯ãç¹å®ã®CPUããµããŒãããããŸããŸãªæäœãè¡šãç¹å¥ãªçªå·ã§ãã ããšãã°ãæ³åäžã®8ãããCPUã®å Žåãæ°å4ã¯ããŒãæäœãè¡šããæ°å5ã¯ä¿åæäœãè¡šããæ°å6ã¯å€ã1å¢ããæäœã§ãã å·Šã®æåã®3ããããæäœçªå·ã§ãããåŸç¶ã®5ãããããã®æäœã§äœ¿çšãããå€ã§ãããšä»®å®ãããšããã®CPUã®ãã·ã³ã³ãŒãã®ãµã³ãã«ããã°ã©ã ã¯æ¬¡ã®ããã«ãªããŸãã
ããŒããŠã§ã¢ã«éåžžã«è¿ãããããã·ã³ã³ãŒãã¯ãã©ã³ããåŠçã®èšé²ãªã©ã®é«ã¬ãã«ã®æŠå¿µãè¡šãã®ã«ã¯é©ããŠããŸããã
ããã°ã©ãã³ã°èšèªã¯ãé«ã¬ãã«ã®æŠå¿µãæ瀺ããæ©èœãåããCPUããã°ã©ãã³ã°ã®å¹æçãªæ¹æ³ã«ãªãããã«èšèšãããŠããŸãã ããã°ã©ãã³ã°èšèªã¯ãããŒããŠã§ã¢ã®å¶éã«å¯ŸåŠããå¿ èŠã¯ãããŸããã 圌ãã®äž»ãªä»äºã¯äœ¿ãããããšè¡šçŸåã§ãã ããã°ã©ãã³ã°èšèªã¯äººã ãããç解ãããããèªç¶èšèªã«è¿ããã®ã§ãã
ãã ããããã°ã©ãã³ã°èšèªã¯ã話ãããŠããã©ã®èšèªãããã¯ããã«å³æ Œã§æ£åŒãªèŠåãé å®ããŠããŸãã
äžéšã®ããã°ã©ãã³ã°èšèªã§ã¯ãå®è¡å¯èœããã°ã©ã ã«ãªãåã«åœä»€ãã³ã³ãã€ã«ããå¿ èŠããããŸãã ãã®ãããªèšèªã¯é«éãªããã°ã©ã ãäœæããŸãããéçºããã»ã¹ã«ã¯2ã€ã®äž»èŠãªã¹ããããå«ãŸããŸããããã°ã©ã ã®äœæãšã³ã³ãã€ã«ã§ãã
äžè¬ã«ãã³ã³ãã€ã«ãããèšèªã¯ãããã°ã©ã ãå®è¡ãéå§ããåã§ãã£ãŠããšã©ãŒãæ€åºããã®ã«åœ¹ç«ã¡ãŸãã
Dã¯ã³ã³ãã€ã«ãããèšèªã§ãã
äžéšã®ããã°ã©ãã³ã°èšèªã¯ã³ã³ãã€ã«ãå¿ èŠãšããŸããã ãã®ãããªèšèªã¯ã€ã³ã¿ããªã¿ãšåŒã°ããŸãã ããã°ã©ã ã¯ãæ°ããå°å·ããããœãŒã¹ã³ãŒãããçŽæ¥èµ·åã§ããŸãã ã€ã³ã¿ããªã¿èšèªã®äŸïŒPythonãRubyãããã³Perlã ã³ã³ãã€ã«æ®µéããªãããããã®ãããªèšèªã§ã¯ããã°ã©ã éçºãç°¡åã«ãªãå ŽåããããŸãã äžæ¹ãããã°ã©ã ã®åœä»€ã¯ãããã°ã©ã ãèµ·åããããã³ã«è§£éã®ããã«è§£æãããå¿ èŠãããããããã®ãããªèšèªã®ããã°ã©ã ã¯ãã³ã³ãã€ã«ãããèšèªã§æžãããåçã®ãã®ãããé ããªããŸãã
éèš³èšèªã®äžè¬çãªå Žåãããã°ã©ã ã®å€ãã®çš®é¡ã®ãšã©ãŒã¯ãå®è¡ãéå§ããããŸã§æ€åºã§ããŸããã
ã³ã³ãã€ã©ã®ç®çã¯ç¿»èš³ã§ããããã°ã©ãã³ã°èšèªã§æžãããããã°ã©ã ãæ©æ¢°èªã«ç¿»èš³ããŸãã ããã¯ãããã°ã©ããŒèšèªããCPUèšèªãžã®ç¿»èš³ã§ãã ãã®ç¿»èš³ã¯ã³ã³ãã€ã«ãšåŒã°ããŸãã åã³ã³ãã€ã©ãŒã¯ç¹å®ã®ããã°ã©ãã³ã°èšèªãç解ãããã®ã³ã³ãã€ã©ãŒãšããŠèšè¿°ãããŸãïŒäŸãã°ããcompiler for DãïŒã
ã³ã³ãã€ã©ãŒã¯èšèªã®èŠåã«åŸã£ãŠããã°ã©ã ãã³ã³ãã€ã«ããããã 誀ã£ãåœä»€ã«å°éãããšããã«ã³ã³ãã€ã«ãåæ¢ããŸãã 誀ã£ãæ瀺ãšã¯ãèšèªä»æ§ããå€ãããã®ã§ãã äžé©åãªãã©ã±ãããã»ãã³ãã³ã®æ¬ èœãããŒã¯ãŒãã®ã¹ãã«ãã¹ãªã©ã®åé¡ -ãã¹ãŠãã³ã³ãã€ã«ãšã©ãŒã®åå ã§ãã
ã³ã³ãã€ã©ã¯ãåé¡ãšãªãå¯èœæ§ã®ããäžå¯©ãªã³ãŒããæ€åºãããšãã«ã³ã³ãã€ã«èŠåãçæããŸãããå¿ ããããšã©ãŒã§ã¯ãããŸããã ãã ããèŠåã¯ã»ãšãã©ã®å Žåãå®éã®ééããŸãã¯äžé©åãªã¹ã¿ã€ã«ã瀺ããŠãããããæãäžè¬çãªæ¹æ³ã¯ãã»ãšãã©ãŸãã¯ãã¹ãŠã®èŠåããšã©ãŒãšããŠæ±ãããšã§ãã
ã³ã³ãã€ã©
Dã§æãäžè¬çã«äœ¿çšãããããŒã«ã¯ã ããã¹ããšãã£ã¿ãŒãšã³ã³ãã€ã©ãŒã§ããããšãå ã«ããããŸãã ã Dã®ããã°ã©ã ã¯ãããã¹ããšãã£ã¿ãŒïŒã䜿ãã®KOïŒã§èšè¿°ãããŠããŸãã
Dãªã©ã®ã³ã³ãã€ã«æžã¿èšèªã䜿çšããå Žåã ã³ã³ãã€ã«ã®æŠå¿µãšã³ã³ãã€ã©ãŒã®æ©èœãç解ããå¿ èŠããããŸãã
ãã·ã³ã³ãŒã
ã³ã³ãã¥ãŒã¿ãŒã®é è³ã¯ãã€ã¯ãããã»ããµãŒïŒãŸãã¯CPUã äžå€®åŠçè£ çœ®ã®ç¥ïŒã§ãã ã³ãŒãã£ã³ã°ã¯CPUãäœããã¹ããã瀺ããã®ã§ããã䜿çšãããåœä»€ã¯ãã·ã³ã³ãŒããšåŒã°ããŸã ã
ã»ãšãã©ã®CPUã¢ãŒããã¯ãã£ã¯ããããã«åºæã®ãã·ã³åºæã®ã³ãŒãã䜿çšããŸãã ãããã®ãã·ã³åœä»€ã¯ãã¢ãŒããã¯ãã£èšèšäžã®ããŒããŠã§ã¢å¶éã«ãã£ãŠæ±ºå®ãããŸãã æäœã¬ãã«ã§ã¯ããããã®åœä»€ã¯é»æ°ä¿¡å·ãšããŠå®è£ ãããŸãã ãã®ã¬ãã«ã§ã®ããã°ã©ãã³ã°ã®åçŽãã¯äž»ãªç®æšã§ã¯ãªããããCPUã®ã³ã³ãã¥ãŒã¿ãŒã³ãŒãã«çŽæ¥ããã°ã©ã ãèšè¿°ããããšã¯éåžžã«é£ããã¿ã¹ã¯ã§ãã
ãããã®ãã·ã³åœä»€ã¯ãç¹å®ã®CPUããµããŒãããããŸããŸãªæäœãè¡šãç¹å¥ãªçªå·ã§ãã ããšãã°ãæ³åäžã®8ãããCPUã®å Žåãæ°å4ã¯ããŒãæäœãè¡šããæ°å5ã¯ä¿åæäœãè¡šããæ°å6ã¯å€ã1å¢ããæäœã§ãã å·Šã®æåã®3ããããæäœçªå·ã§ãããåŸç¶ã®5ãããããã®æäœã§äœ¿çšãããå€ã§ãããšä»®å®ãããšããã®CPUã®ãã·ã³ã³ãŒãã®ãµã³ãã«ããã°ã©ã ã¯æ¬¡ã®ããã«ãªããŸãã
Operation Value Meaning 100 11110 LOAD 11110 101 10100 STORE 10100 110 10100 INCREMENT 10100 000 00000 PAUSE
ããŒããŠã§ã¢ã«éåžžã«è¿ãããããã·ã³ã³ãŒãã¯ãã©ã³ããåŠçã®èšé²ãªã©ã®é«ã¬ãã«ã®æŠå¿µãè¡šãã®ã«ã¯é©ããŠããŸããã
ããã°ã©ãã³ã°èšèª
ããã°ã©ãã³ã°èšèªã¯ãé«ã¬ãã«ã®æŠå¿µãæ瀺ããæ©èœãåããCPUããã°ã©ãã³ã°ã®å¹æçãªæ¹æ³ã«ãªãããã«èšèšãããŠããŸãã ããã°ã©ãã³ã°èšèªã¯ãããŒããŠã§ã¢ã®å¶éã«å¯ŸåŠããå¿ èŠã¯ãããŸããã 圌ãã®äž»ãªä»äºã¯äœ¿ãããããšè¡šçŸåã§ãã ããã°ã©ãã³ã°èšèªã¯äººã ãããç解ãããããèªç¶èšèªã«è¿ããã®ã§ãã
if (a_card_has_been_played()) { display_the_card(); }
ãã ããããã°ã©ãã³ã°èšèªã¯ã話ãããŠããã©ã®èšèªãããã¯ããã«å³æ Œã§æ£åŒãªèŠåãé å®ããŠããŸãã
ã³ã³ãã€ã«ãããèšèª
äžéšã®ããã°ã©ãã³ã°èšèªã§ã¯ãå®è¡å¯èœããã°ã©ã ã«ãªãåã«åœä»€ãã³ã³ãã€ã«ããå¿ èŠããããŸãã ãã®ãããªèšèªã¯é«éãªããã°ã©ã ãäœæããŸãããéçºããã»ã¹ã«ã¯2ã€ã®äž»èŠãªã¹ããããå«ãŸããŸããããã°ã©ã ã®äœæãšã³ã³ãã€ã«ã§ãã
äžè¬ã«ãã³ã³ãã€ã«ãããèšèªã¯ãããã°ã©ã ãå®è¡ãéå§ããåã§ãã£ãŠããšã©ãŒãæ€åºããã®ã«åœ¹ç«ã¡ãŸãã
Dã¯ã³ã³ãã€ã«ãããèšèªã§ãã
éèš³èšèª
äžéšã®ããã°ã©ãã³ã°èšèªã¯ã³ã³ãã€ã«ãå¿ èŠãšããŸããã ãã®ãããªèšèªã¯ã€ã³ã¿ããªã¿ãšåŒã°ããŸãã ããã°ã©ã ã¯ãæ°ããå°å·ããããœãŒã¹ã³ãŒãããçŽæ¥èµ·åã§ããŸãã ã€ã³ã¿ããªã¿èšèªã®äŸïŒPythonãRubyãããã³Perlã ã³ã³ãã€ã«æ®µéããªãããããã®ãããªèšèªã§ã¯ããã°ã©ã éçºãç°¡åã«ãªãå ŽåããããŸãã äžæ¹ãããã°ã©ã ã®åœä»€ã¯ãããã°ã©ã ãèµ·åããããã³ã«è§£éã®ããã«è§£æãããå¿ èŠãããããããã®ãããªèšèªã®ããã°ã©ã ã¯ãã³ã³ãã€ã«ãããèšèªã§æžãããåçã®ãã®ãããé ããªããŸãã
éèš³èšèªã®äžè¬çãªå Žåãããã°ã©ã ã®å€ãã®çš®é¡ã®ãšã©ãŒã¯ãå®è¡ãéå§ããããŸã§æ€åºã§ããŸããã
ã³ã³ãã€ã©
ã³ã³ãã€ã©ã®ç®çã¯ç¿»èš³ã§ããããã°ã©ãã³ã°èšèªã§æžãããããã°ã©ã ãæ©æ¢°èªã«ç¿»èš³ããŸãã ããã¯ãããã°ã©ããŒèšèªããCPUèšèªãžã®ç¿»èš³ã§ãã ãã®ç¿»èš³ã¯ã³ã³ãã€ã«ãšåŒã°ããŸãã åã³ã³ãã€ã©ãŒã¯ç¹å®ã®ããã°ã©ãã³ã°èšèªãç解ãããã®ã³ã³ãã€ã©ãŒãšããŠèšè¿°ãããŸãïŒäŸãã°ããcompiler for DãïŒã
ã³ã³ãã€ã«ãšã©ãŒ
ã³ã³ãã€ã©ãŒã¯èšèªã®èŠåã«åŸã£ãŠããã°ã©ã ãã³ã³ãã€ã«ããããã 誀ã£ãåœä»€ã«å°éãããšããã«ã³ã³ãã€ã«ãåæ¢ããŸãã 誀ã£ãæ瀺ãšã¯ãèšèªä»æ§ããå€ãããã®ã§ãã äžé©åãªãã©ã±ãããã»ãã³ãã³ã®æ¬ èœãããŒã¯ãŒãã®ã¹ãã«ãã¹ãªã©ã®åé¡ -ãã¹ãŠãã³ã³ãã€ã«ãšã©ãŒã®åå ã§ãã
ã³ã³ãã€ã©ã¯ãåé¡ãšãªãå¯èœæ§ã®ããäžå¯©ãªã³ãŒããæ€åºãããšãã«ã³ã³ãã€ã«èŠåãçæããŸãããå¿ ããããšã©ãŒã§ã¯ãããŸããã ãã ããèŠåã¯ã»ãšãã©ã®å Žåãå®éã®ééããŸãã¯äžé©åãªã¹ã¿ã€ã«ã瀺ããŠãããããæãäžè¬çãªæ¹æ³ã¯ãã»ãšãã©ãŸãã¯ãã¹ãŠã®èŠåããšã©ãŒãšããŠæ±ãããšã§ãã
åºæ¬çãªã¿ã€ã
åã«ãCPUã¯ã³ã³ãã¥ãŒã¿ãŒã®é è³ã§ããããšãããããŸããã ã»ãšãã©ã®ããã°ã©ã ã¿ã¹ã¯ã¯CPUã§å®è¡ãããæ®ãã¯ã³ã³ãã¥ãŒã¿ãŒã®ä»ã®éšåã«åæ£ãããŸãã
ã³ã³ãã¥ãŒã¿ãŒã®ããŒã¿ã®æå°åäœã¯ããããšåŒã°ãã0ãŸãã¯1ã§ãã
å€0ãŸãã¯1ã®ã¿ãå«ãããšãã§ããããŒã¿åã®äœ¿çšã¯éåžžã«éãããŠãããããCPUã¯è€æ°ãããã®çµã¿åããã§ãããã倧ããªããŒã¿åãå®çŸ©ããŸãã ããšãã°ã ãã€ãã«ã¯8ããããå«ãŸããŸãã CPUãããã¯ãæãçç£çãªããŒã¿åã«ãã£ãŠæ±ºãŸããŸãã32ãããCPUã64ãããCPUãªã©ã§ãã
CPUã«ãã£ãŠå®çŸ©ãããã¿ã€ãã¯ãŸã ååã§ã¯ãããŸããã çåŸã®ååããã©ã³ãã®ãããªé«ã¬ãã«ã®æŠå¿µãèšè¿°ããããšã¯ã§ããŸããã Dã¯å€ãã®æçšãªããŒã¿åãæäŸããŸããããããã®åã§ããå€ãã®é«ã¬ãã«ã®æŠå¿µã説æããã«ã¯äžååã§ãã ãã®ãããªæŠå¿µã¯ãããã°ã©ããæ§é ïŒæ§é ïŒãŸãã¯ã¯ã©ã¹ ïŒã¯ã©ã¹ïŒãšããŠå®çŸ©ããå¿ èŠããããŸããããã«ã€ããŠã¯ã次ã®ç« ã§èª¬æããŸãã
Dã®åºæ¬ã¿ã€ãã¯ã次ã®è¡šã«ç€ºãããã«ãä»ã®å€ãã®èšèªã®åºæ¬ã¿ã€ããšéåžžã«ãã䌌ãŠããŸãã ãã®è¡šã«è¡šç€ºãããçšèªã«ã€ããŠã以äžã§èª¬æããŸãã
çš®é¡ | å®çŸ© | åæå€ |
---|---|---|
ããŒã« | ããŒã«å€True / False | åœ |
ãã€ã | 8ãããã®ç¬Šå·ä»ãçªå· | 0 |
ãŠãã€ã | 8ããã笊å·ãªãæ° | 0 |
çã | 16ãããã®ç¬Šå·ä»ãæ° | 0 |
çã | 16ããã笊å·ãªãæ° | 0 |
int | 32ãããæ°ã®cosç¬Šå· | 0 |
è人 | 32ãããã®ç¬Šå·ãªãæ°å€ | 0 |
é·ã | 64ãããã®ç¬Šå·ä»ãçªå· | 0 |
ãŠãã³ | 64ãããã®ç¬Šå·ãªãæ°å€ | 0 |
æµ®ã | 32ãããæµ®åå°æ°ç¹å®æ° | float.nan |
ããã« | 64ãããæµ®åå°æ°ç¹å®æ° | double.nan |
æ¬åœã® | ããŒããŠã§ã¢ã§ãµããŒããããæé«ã®æµ®åå°æ°ç¹æ° | real.nan |
ã€ãããŒã | floatã®è€çŽ æ°ã®èæ°éš | float.nan * 1.0i |
idouble | doubleã®è€çŽ æ°ã®èæ°éš | double.nan * 1.0i |
ã€ãªã¢ã« | å®æ°ã®è€çŽ æ°ã®èæ°éš | real.nan * 1.0i |
æµ®ã | è€éãªãªãã·ã§ã³ãããŒã | float.nan + float.nan * 1.0i |
äºé | è€éãªããã« | double.nan + double.nan * 1.0i |
ç©ç© | è€éãªãªãã·ã§ã³ | real.nan + real.nan * 1.0i |
ãã£ãŒ | UTF-8æåïŒã³ãŒããã€ã³ãïŒ | 0xFF |
wchar | UTF-16æåïŒã³ãŒããã€ã³ãïŒ | 0xFFFF |
dchar | UTF-32æåïŒã³ãŒããã€ã³ãïŒ | 0x0000FFFF |
äžèšã«å ããŠã voidããŒã¯ãŒãã¯typeã§ã¯ãªããšã³ãã£ãã£ãèšè¿°ããŸãã ããŒã¯ãŒãcentããã³ucent㯠ãå°æ¥ã®äœ¿çšã®ããã«ã笊å·ä»ãããã³ç¬Šå·ãªãã®128ãããå€ãè¡šãããã«äºçŽãããŠããŸãã
ç¹å¥ãªçç±ããªãéããã»ãšãã©ã®å€ã«intã䜿çšã§ããŸãã å°æ°éšãå«ãæŠå¿µãè¡šãããã«ã doubleãæ€èšããŠãã ããã
è¡šã«ç€ºãããŠããæŠå¿µã®èª¬æ
ããŒã« ïŒ trueã®å Žåã¯trueã falseã®å Žåã¯falseã«ãªãããŒã«åŒã®ã¿ã€ãã
笊å·ã¿ã€ãïŒè² ã®å€ãšæ£ã®å€ãåãããšãã§ããã¿ã€ãã ããšãã°ã byteã¯0ã255ã®å€ãæã€ããšãã§ããŸãããããã®åã®ååã®å é ã«ããæåuã¯ã unsignedãšããåèªããååŸãããŸãã
æµ®åå°æ°ç¹æ°ïŒã¿ã€ãã¯ã1.25ã®ããã«ãå°æ°ã®å€ãè¡šãå ŽåããããŸãã æµ®åå°æ°ç¹èšç®ã®ç²ŸåºŠã¯ãåã®ãããæ°ã«çŽæ¥äŸåããŸãããããæ°ãå€ãã»ã©ãããæ£ç¢ºãªçµæãåŸãããŸãã
æµ®åå°æ°ç¹æ°ã®ã¿ãå°æ°ãè¡šãããšãã§ããŸãã æŽæ°åïŒäŸïŒ int ïŒã¯ã1ã2ãªã©ã®å€ã®ã¿ãä¿æã§ããŸãã
è€çŽ æ°åïŒãããã®åã¯ãæ°åŠã®è€çŽ æ°ãè¡šãããšãã§ããŸãã
æ°ã®èæ°åïŒãããã®åã¯ãè€çŽ æ°ã®èæ°éšã®ã¿ãè¡šãããšãã§ããŸãã åæå€ã®åã«ããæ°åŠã®æåiã¯ã-1ã®å¹³æ¹æ ¹ã§ãã
nanïŒ ç¡å¹ãªæµ®åå°æ°ç¹å€ãè¡šããnot a numberãã®é åèªã
笊å·ã¿ã€ãïŒè² ã®å€ãšæ£ã®å€ãåãããšãã§ããã¿ã€ãã ããšãã°ã byteã¯0ã255ã®å€ãæã€ããšãã§ããŸãããããã®åã®ååã®å é ã«ããæåuã¯ã unsignedãšããåèªããååŸãããŸãã
æµ®åå°æ°ç¹æ°ïŒã¿ã€ãã¯ã1.25ã®ããã«ãå°æ°ã®å€ãè¡šãå ŽåããããŸãã æµ®åå°æ°ç¹èšç®ã®ç²ŸåºŠã¯ãåã®ãããæ°ã«çŽæ¥äŸåããŸãããããæ°ãå€ãã»ã©ãããæ£ç¢ºãªçµæãåŸãããŸãã
æµ®åå°æ°ç¹æ°ã®ã¿ãå°æ°ãè¡šãããšãã§ããŸãã æŽæ°åïŒäŸïŒ int ïŒã¯ã1ã2ãªã©ã®å€ã®ã¿ãä¿æã§ããŸãã
è€çŽ æ°åïŒãããã®åã¯ãæ°åŠã®è€çŽ æ°ãè¡šãããšãã§ããŸãã
æ°ã®èæ°åïŒãããã®åã¯ãè€çŽ æ°ã®èæ°éšã®ã¿ãè¡šãããšãã§ããŸãã åæå€ã®åã«ããæ°åŠã®æåiã¯ã-1ã®å¹³æ¹æ ¹ã§ãã
nanïŒ ç¡å¹ãªæµ®åå°æ°ç¹å€ãè¡šããnot a numberãã®é åèªã
翻蚳è
ã®ã³ã¡ã³ã
æµ®åå°æ°ç¹æ°ã®å ŽåãNaNå€ãåæååãšããŠäœ¿çšãããã®ã¯å¥åŠã«æãããããããŸããã éçºè
ããã®å
¬åŒèª¬æïŒãã®ç«å Žã«ã¯åæããŸãããïŒïŒ
NaNã«ã¯ã䜿çšããæäœã«é¢ä¿ãªããçµæãåã³NaNã«ãªããšããèå³æ·±ãç¹æ§ããããŸãã ãããã£ãŠãNaNã¯é åžããã䜿çšããããã¹ãŠã®èšç®ã®çµæã«ãªããŸãã ããã¯ãçªç¶è¡šç€ºãããNaNããåæåãããŠããªãå€æ°ã䜿çšãããããšãæ確ã«ç€ºãã€ã³ãžã±ãŒã¿ãŒã§ããããšãæå³ããŸãã
0.0ãåæå€ãšããŠäœ¿çšãããå Žåããã®çµæã¯åºåã§ç®ç«ããªããããåæåãããã©ã«ãã§æå³çã§ãªãå Žåããã°ã¯æ°ä»ãããªãå¯èœæ§ããããŸãã
ããã©ã«ãã®ã€ãã·ã£ã©ã€ã¶ãæçšãªå€ã§ããã¹ãã§ã¯ãªãããã®ç®çã¯ãã°ãéãããšã§ãã NaNã¯ãã®åœ¹å²ã«é©ããŠããŸãã
ãããããã¡ãããã³ã³ãã€ã©ãŒã¯åæåãããŠããªãå€æ°ã«é¢ãããšã©ãŒãæ€åºããŠçæã§ããŸããïŒ ã»ãšãã©ã®å Žåãåžžã«ã§ã¯ãããŸããããããŒã¿ãããŒã®å éšåæã®è€éãã«äŸåããŸãã ãããã£ãŠããã®ã¡ã«ããºã ã®åžæã¯ãèããããªãä¿¡é Œæ§ã®äœããœãªã¥ãŒã·ã§ã³ã§ãã
CPUå®è£ ã®ä»æ§ã«ãããNaNã¯æŽæ°ããªããããDã¯ä»£ããã«0ã䜿çšããŸãããŒãã®å€ã¯ãNaNã®ãããªãšã©ãŒãæ€åºããå©ç¹ã¯ãããŸããããå°ãªããšãæå³ããªãåæåããã®ãšã©ãŒã¯åçŸå¯èœã§ããããããã£ãŠãããããã°ãããŸãã
NaNã«ã¯ã䜿çšããæäœã«é¢ä¿ãªããçµæãåã³NaNã«ãªããšããèå³æ·±ãç¹æ§ããããŸãã ãããã£ãŠãNaNã¯é åžããã䜿çšããããã¹ãŠã®èšç®ã®çµæã«ãªããŸãã ããã¯ãçªç¶è¡šç€ºãããNaNããåæåãããŠããªãå€æ°ã䜿çšãããããšãæ確ã«ç€ºãã€ã³ãžã±ãŒã¿ãŒã§ããããšãæå³ããŸãã
0.0ãåæå€ãšããŠäœ¿çšãããå Žåããã®çµæã¯åºåã§ç®ç«ããªããããåæåãããã©ã«ãã§æå³çã§ãªãå Žåããã°ã¯æ°ä»ãããªãå¯èœæ§ããããŸãã
ããã©ã«ãã®ã€ãã·ã£ã©ã€ã¶ãæçšãªå€ã§ããã¹ãã§ã¯ãªãããã®ç®çã¯ãã°ãéãããšã§ãã NaNã¯ãã®åœ¹å²ã«é©ããŠããŸãã
ãããããã¡ãããã³ã³ãã€ã©ãŒã¯åæåãããŠããªãå€æ°ã«é¢ãããšã©ãŒãæ€åºããŠçæã§ããŸããïŒ ã»ãšãã©ã®å Žåãåžžã«ã§ã¯ãããŸããããããŒã¿ãããŒã®å éšåæã®è€éãã«äŸåããŸãã ãããã£ãŠããã®ã¡ã«ããºã ã®åžæã¯ãèããããªãä¿¡é Œæ§ã®äœããœãªã¥ãŒã·ã§ã³ã§ãã
CPUå®è£ ã®ä»æ§ã«ãããNaNã¯æŽæ°ããªããããDã¯ä»£ããã«0ã䜿çšããŸãããŒãã®å€ã¯ãNaNã®ãããªãšã©ãŒãæ€åºããå©ç¹ã¯ãããŸããããå°ãªããšãæå³ããªãåæåããã®ãšã©ãŒã¯åçŸå¯èœã§ããããããã£ãŠãããããã°ãããŸãã
ã¿ã€ãã®ããããã£
Dã§ã¯ãåã«ããããã£ããããŸã ã ããããã£ã®å€ãååŸããã«ã¯ãã¿ã€ãã®åŸã«ããããä»ããŠããããã£ã®ååãæžã蟌ãå¿ èŠããããŸãã ããšãã°ã sizeof intããããã£ã¯int.sizeofã®ããã«åŒã³åºãããŸãã ãã®ç« ã§ã¯ã次ã®4ã€ã®å±æ§ã«ã€ããŠã®ã¿èª¬æããŸãã
- stringofïŒã¿ã€ãå
- sizeofïŒãã€ãåäœã®ã¿ã€ããµã€ãºïŒãããæ°ã¯8åïŒ
- minïŒåãåãããšãã§ããæå°å€
- maxïŒåãåãããšãã§ããæ倧å€
intã®ãããã®ããããã£ãåºåããããã°ã©ã
ã€ã³ããŒãæšæº stdio ;
ãã€ãã¡ã€ã³ïŒ ïŒ
{
writeln ïŒ "TypeïŒ" ã intãstringof ïŒ ;
writeln ïŒ "ãã€ãåäœã®é·ãïŒ" ã intãsizeof ïŒ ;
writeln ïŒ "æå°å€ïŒ" ã intãmin ïŒ ;
writeln ïŒ "æ倧å€ïŒ" ã intãmax ïŒ ;
}
翻蚳è
ã¡ã¢
size_t
ãŸãã size_tã¿ã€ãããããŸãããã®ååã¯ããµã€ãºã¿ã€ãããè¡šããŠããŸãã ããã¯ç¬ç«åã§ã¯ãªãã笊å·ãªãåã®ãšã€ãªã¢ã¹ã§ãããã¡ã¢ãªå ã®ãã¹ãŠã®å¯èœãªã¢ãã¬ã¹ãè¡šãã®ã«ååã§ãã ãããã£ãŠããã®ã¿ã€ãã¯ã·ã¹ãã ã«ãã£ãŠç°ãªããŸã ã32ãããã·ã¹ãã ã§ã¯uint ã64ãããã·ã¹ãã ã§ã¯ulongãªã©ã§ãã
.stringofããããã£ã䜿çšããŠãã·ã¹ãã ã§size_tãåç §ããåã確èªã§ããŸãã
ã³ãŒã
ç§ã®ã·ã¹ãã ã®åºåïŒ
ã€ã³ããŒãæšæº stdio ;
ãã€ãã¡ã€ã³ïŒ ïŒ
{
writeln ïŒ size_tãstringof ïŒ ;
}
ç§ã®ã·ã¹ãã ã®åºåïŒ
ulong
æŒç¿
ä»ã®ã¿ã€ãã®ããããã£ãå°å·ããŸãã
泚 ïŒ äºçŽæžã¿ã®ã¿ã€ãcentããã³ucentã¯ãã©ã®ããã°ã©ã ã§ã䜿çšã§ããŸããã äŸå€ãšããŠã voidã«ã¯.minããã³.maxããããã£ããããŸãã ã
泚 ïŒ äºçŽæžã¿ã®ã¿ã€ãcentããã³ucentã¯ãã©ã®ããã°ã©ã ã§ã䜿çšã§ããŸããã äŸå€ãšããŠã voidã«ã¯.minããã³.maxããããã£ããããŸãã ã
解決ç
ã€ã³ããŒãæšæº stdio ;
ãã€ãã¡ã€ã³ïŒ ïŒ
{
writeln ïŒ "TypeïŒ" ã shortãstringof ïŒ ;
writeln ïŒ "ãã€ãåäœã®ãµã€ãºïŒ" ã shortãsizeof ïŒ ;
writeln ïŒ "æå°å€ïŒ" ã shortãmin ïŒ ;
writeln ïŒ "æ倧å€ïŒ" ã shortãmax ïŒ ;
writeln ïŒ ïŒ ;
writeln ïŒ "TypeïŒ" ã ulongãstringof ïŒ ;
writeln ïŒ "ãã€ãåäœã®ãµã€ãºïŒ" ã ulongãsizeof ïŒ ;
writeln ïŒ "æå°å€ïŒ" ã ulongãmin ïŒ ;
writeln ïŒ "æ倧å€ïŒ" ã ulongãmax ïŒ ;
}
åºæ
ããã°ã©ãã³ã°ã®åŠçãåŸ ã€æåã®2ã€ã®é害ã¯ãä»£å ¥æŒç®åãšèšç®ã®é åºã§ãã
ã»ãšãã©ãã¹ãŠã®ããã°ã©ã ãã»ãšãã©ãã¹ãŠã®ããã°ã©ãã³ã°èšèªã§åæ§ã®è¡ãèŠã€ãããŸãã
ãã®è¡ã®æå³ã¯ããå€ã10ã«çãããããã§ãã åæ§ã«ã次ã®è¡ã¯ãmake b equal to 20ããæå³ããŸãã
äžèšã®æ å ±ã«åºã¥ããŠã次ã®è¡ã¯ã©ãã§ããïŒ
æ®å¿µãªããšã«ããã®è¡ã«ã¯æ°åŠã®æ¯èŒæŒç®åãå«ãŸããŠããŸãããã誰ããç¥ã£ãŠãããšæããŸãã äžèšã®è¡šçŸã¯ãa is bããšããæå³ã§ã¯ãããŸãã ïŒ åã®2è¡ãšåãããžãã¯ã䜿çšããå Žåãäžèšã®åŒã¯ã aã®å€ãbã®å€ãšçãããããããšãæå³ããå¿ èŠããããŸãã
æ°åŠã§ããç¥ãããŠããã·ã³ãã«=ã¯ãããã°ã©ãã³ã°ã§ã¯ãŸã£ããç°ãªãæå³ãæã¡ãŸãããå·ŠåŽã®å€ãå³åŽã®å€ãšçãããããã
ããã°ã©ã æäœã¯ãç¹å®ã®é åºã§æ®µéçã«å®è¡ãããŸãã ããã°ã©ã å ã®åã®3ã€ã®åŒã¯ã次ã®é åºã§èŠãããšãã§ããŸãã
ãããã®è¡ã®æå³ã¯ãã aã®å€ã10ã«èšå®ãã bã®å€ã20ã«èšå®ãã aã®å€ãbã®å€ã«çãããããã§ãã ãããã£ãŠããããã®3ã€ã®æäœãå®è¡ãããšã aãšbã¯äž¡æ¹ãšã20ã«ãªããŸãã
次ã®3ã€ã®æäœãaãšbã®å€ã亀æããæ¹æ³ãåŠã³ãŸãã æåã«ãããã®å€ããããã1ãš2ã«çããå Žåãæäœãå®è¡ããåŸãå€ã¯2ãš1ã«çãããªããŸãã
å²ãåœãŠæŒç®åãšèšç®é åº
ããã°ã©ãã³ã°ã®åŠçãåŸ ã€æåã®2ã€ã®é害ã¯ãä»£å ¥æŒç®åãšèšç®ã®é åºã§ãã
ä»£å ¥æŒç®å
ã»ãšãã©ãã¹ãŠã®ããã°ã©ã ãã»ãšãã©ãã¹ãŠã®ããã°ã©ãã³ã°èšèªã§åæ§ã®è¡ãèŠã€ãããŸãã
a = 10;
ãã®è¡ã®æå³ã¯ããå€ã10ã«çãããããã§ãã åæ§ã«ã次ã®è¡ã¯ãmake b equal to 20ããæå³ããŸãã
b = 20;
äžèšã®æ å ±ã«åºã¥ããŠã次ã®è¡ã¯ã©ãã§ããïŒ
a = b;
æ®å¿µãªããšã«ããã®è¡ã«ã¯æ°åŠã®æ¯èŒæŒç®åãå«ãŸããŠããŸãããã誰ããç¥ã£ãŠãããšæããŸãã äžèšã®è¡šçŸã¯ãa is bããšããæå³ã§ã¯ãããŸãã ïŒ åã®2è¡ãšåãããžãã¯ã䜿çšããå Žåãäžèšã®åŒã¯ã aã®å€ãbã®å€ãšçãããããããšãæå³ããå¿ èŠããããŸãã
æ°åŠã§ããç¥ãããŠããã·ã³ãã«=ã¯ãããã°ã©ãã³ã°ã§ã¯ãŸã£ããç°ãªãæå³ãæã¡ãŸãããå·ŠåŽã®å€ãå³åŽã®å€ãšçãããããã
èšç®é åº
ããã°ã©ã æäœã¯ãç¹å®ã®é åºã§æ®µéçã«å®è¡ãããŸãã ããã°ã©ã å ã®åã®3ã€ã®åŒã¯ã次ã®é åºã§èŠãããšãã§ããŸãã
a = 10; b = 20; a = b;
ãããã®è¡ã®æå³ã¯ãã aã®å€ã10ã«èšå®ãã bã®å€ã20ã«èšå®ãã aã®å€ãbã®å€ã«çãããããã§ãã ãããã£ãŠããããã®3ã€ã®æäœãå®è¡ãããšã aãšbã¯äž¡æ¹ãšã20ã«ãªããŸãã
éå
次ã®3ã€ã®æäœãaãšbã®å€ã亀æããæ¹æ³ãåŠã³ãŸãã æåã«ãããã®å€ããããã1ãš2ã«çããå Žåãæäœãå®è¡ããåŸãå€ã¯2ãš1ã«çãããªããŸãã
c = a; a = b; b = c;
解決ç
å€a ã bãããã³c㯠ãåæäœã®å³åŽã«å°å·ãããŸãã
æåŸã«ã aãšbã®å€ã亀æãããŸãã
â a 1, b 2, c c = a â a 1, b 2, c 1 a = b â a 2, b 2, c 1 b = c â a 2, b 1, c 1
æåŸã«ã aãšbã®å€ã亀æãããŸãã