Dab tsi yog qhov tsis tau kos npe byte?
Dab tsi yog qhov tsis tau kos npe byte?

Video: Dab tsi yog qhov tsis tau kos npe byte?

Video: Dab tsi yog qhov tsis tau kos npe byte?
Video: Hmong Tias Peb yog XaXaj lawm ua tsis tau dab tsi lawm. 2024, Hlis ntuj nqeg
Anonim

Kos npe thiab Tsis tau kos npe . Ib tsis tau kos npe integer yog xoom los yog zoo. Hauv Java (tsis hais lub khoos phis tawj platform) yog hom qub byte tuav ib tug integer ntawm -128 rau +127. Ib unsigned byte tuav tus nqi 0 txog +255, yog li ib yam dab tsi loj dua datatype byte xav tau.

Ib sab ntawm no, puas yog byte kos npe lossis tsis kos npe?

8 Teb. Kos npe variables, xws li kos npe integers yuav tso cai rau koj los sawv cev tus lej ob qho tib si hauv qhov zoo thiab qhov tsis zoo. Piv txwv li, ib qho unsigned byte tuaj yeem sawv cev qhov tseem ceeb ntawm 0 txog 255, thaum kos npe byte tuaj yeem sawv cev -128 txog 127.

Ib sab saum toj, txhais li cas kom tsis tau kos npe? Unsigned txhais tau tias non-negative Lub sij hawm " tsis tau kos npe " hauv computer programming qhia txog qhov sib txawv uas tuaj yeem tuav cov lej zoo xwb. Lo lus "kos npe" hauv computer code qhia tias qhov sib txawv tuaj yeem tuav qhov tsis zoo thiab qhov zoo.

Tsis tas li ntawd, hom ntaub ntawv tsis tau kos npe yog dab tsi?

Cov tsis tau kos npe lo lus tseem ceeb yog a hom ntaub ntawv specifier, uas ua rau a sib txawv tsuas yog sawv cev rau cov zauv (cov lej zoo thiab xoom). Nws tuaj yeem siv rau lub char, luv, int thiab ntev hom . Piv txwv li, yog tias ib qho int feem ntau tuav qhov tseem ceeb ntawm -32768 txog 32767, ib qho tsis tau kos npe int yuav tuav tus nqi ntawm 0 txog 65535.

Unsigned txhais li cas hauv binary?

Unsigned binary zauv yog , los ntawm txhais , tus lej zoo thiab yog li ntawd ua tsis xav tau tus lej lej. Ib m-bit tsis tau kos npe tus lej sawv cev rau txhua tus lej hauv thaj tsam 0 txog 2m - 1. Piv txwv li, qhov ntau ntawm 8-ntsis tsis kos npe binary zauv yog 0 rau 25510 hauv decimal thiab los ntawm 00 rau FF16 hauv hexadecimal.

Pom zoo: