Menene menene? · bei.pm

Wannan rubutun an fassara shi ta atomatik ta hanyar OpenAI GPT-4o Mini

A wannan sashe akwai makaloli akan tsarin fayiloli da kuma dawowar injiniya.

Yanzu haka, akwai yare masu shirye-shirye da yawa a waje, da kuma mutane da yawa suna sanin wasu abubuwa da sunaye daban-daban - ko kuma ba su da masaniya game da kasancewar abubuwa masu mahimmanci, saboda yaren shirye-shiryensu ya raba su daga gare su.

tl;dr:
Alamar na yana da kusan alaka da C99 <stdint.h>. Wanda zai iya fahimtar wannan alamar, tabbas zai iya amfani da alamar ta.

Adadi

Integer suna nufin lambobin gaske ne, wato lambobin da ba su da rabo.

A cikin tsarin bayanai, Integer yawanci ana bayyana su a cikin takamaiman adadin lambobi, kamar yadda aka bayyana a cikin bit - saboda haka, "Byte" da nau'ikan da ke gudana daga gare shi (Word, Qword, ...) yawanci suna dogara ga dandalin.

Haka kuma, ana bambanta tsakanin lambobin halitta (ℕ, wato, ba tare da alamar rashin kyau ba - Unsigned) da lambobin gaske (ℤ, wato, tare da alamar rashin kyau - Signed).
Wannan bayani yana bayyana ta hanyar alamar a cikin sunan (u ko s).

Hakanan yana yiwuwa cewa lambobin gaske masu alamar rashin kyau suna iya zama a matsayin Einerkomplement ko kuma a matsayin Zweierkomplement.
Duk da cewa ba a bayyana hakan ba, ana amfani da Zweierkomplement saboda yana zama tsarin da aka fi so a cikin zamani na fasahar kwamfuta.

Na bayyana lambobin da ba su da alamar rashin kyau a cikin takarduna na a matsayin uint, tare da bayanin ingancin a cikin Bits.
Lambobin da ke da alamar rashin kyau ana bayyana su a cikin takarduna na a matsayin sint, haka nan tare da bayanin ingancin a cikin Bits.

Na yi watsi da amfani da nau'in bayanai "char" don haruffa, saboda jerin haruffa yawanci suna wakiltar jerin lambobi tare da fassarar musamman.
Saboda haka, ana wakilta su a matsayin uint(8)[].

Misalan:

Alamomi C99 stdint.h-Maqasudi Bayani Wurin Lambobi
uint(16) uint16_t Integer ba tare da alama ba, tsawon Bit 16 0 - 65.535
sint(8) int8_t Integer tare da alama, tsawon Bit 8, kariyar biyu -126 - 127
uint(24) uint32_t:24 Integer ba tare da alama ba, tsawon Bit 24 0 - 16.777.216

Darajar Festkomma

Darajar Festkomma suna nufin ƙididdiga daga fannonin Ƙididdigar Gaskiya (Q), wanda hakan ke nufin suna da ƙoma da kuma ƙananan lambobi.

Domin darajar Festkomma, wato dalilin sunan, wurin ƙoman yana cikin yanayin bayanin bayanai.
Hakan yana nufin akwai takamaiman yawan lambobi ga wannan nau'in bayanai; bisa lissafi, wannan yawan lambobi yana ƙarami.

A ainihin rayuwa, wannan nau'in bayanai yana amfani da shi musamman a kan dandamali marasa isasshen saurin kayan aikin lissafi na ƙididdiga, saboda ana iya lissafa darajar Festkomma ta hanyar kayan aikin integer.

Hakanan wannan nau'in bayanai yana amfani da shi, misali, daga tsarin gudanar da bayanai, idan bukatu na dindindin suna buƙatar cika.
A nan, misali, a tsarin adana bayanan kuɗi na dindindin; mafi yawan kudade suna iyakance ga lambobi 2 bayan ƙoma. (Amma ba daidai bane a yi amfani da darajar Festkomma a nan; mafi kyau shine a ajiye kananan ƙananan kuɗi a matsayin integer kuma a bar sauran matsayin wakilcin)

Kamar yadda na yi da bayanan integer, ina bayyana yawan lambobina na darajar Festkomma kafin da bayan ƙoma:
ufixed(9,7) yana nufin nau'in bayanai wanda ba tare da alamar ba ya tanadi bit 9 don ƙimar kafin ƙoma, da kuma bit 7 don ƙimar bayan ƙoma; a jimlace yana da fadin bit 16 kuma haka yana iya zama a matsayin vector na integers guda biyu masu zaman kansu suna rufe yawan daga (0,0) zuwa (511,127).
Wannan fassarar za ta ba da lambobi 28 a cikin wakilcin lissafi wanda ba a amfani da su ba, saboda ana iya iyakance wa a aikace zuwa (511,99).

Maimakon fassarar kai tsaye na darajar Festkomma a matsayin vector na integers guda 2 - wanda a kowane lokaci yana nufin akwai yanki na bayanai da ba a amfani da su ba lokacin canzawa zuwa lambobin lissafi da kuma juyawa da hannu - ana iya fassara yankin ƙananan lambobi a matsayin kashi na dukkanin yawan lambobin.
A misalin da aka ambata na ufixed(9,7) ana samun kashi tare da ƙimar 27 - yawan lambobin suna daga 0,00 zuwa 511 + 126127 Don canzawa zuwa wakilcin lissafi, za a raba ƙananan lambobin da 128.
Ta wannan hanyar, za a iya gudanar da ayyukan lissafi cikin sauƙi, saboda juyawa yana faruwa ta atomatik, wanda wannan hanya yawanci ana fifita.
Duk da haka, wannan hanya tana da rashin fa'ida cewa ƙananan lambobin a cikin wakilcin lissafi ba su da tabbataccen ƙimar ƙuduri, ma'ana cewa kowane ƙananan lamba ba ta daidai da 0.01, amma 0.007874, wanda zai haifar da kuskuren zagaye.

Wanne hanyar fassara aka yi amfani da ita za a rubuta a wurin da aka yi amfani da ita.

Darajoji na ƙididdiga masu yawan jujjuka

Matsayin Gleitkomma su ne ma'anoni masu wahala daga lissafi, inda aka bayyana lamba mai cikakken tsarin sa ta hanyar wani bayani na lissafi don yin hakan ta hanyar motsawa - wanda ke danganta kai tsaye da rubutun kimiyya.
Hanyar da aka fi amfani da ita don aiwatar da wannan an tsareta tare da IEEE 754 kuma tun daga lokacin an amince da ita a duniya.

A cikin wannan, yawanci matsayi na Gleitkomma yana kunshe da wadannan sassa:

Alamar (0 ko 1) Exponent Mantisse

Yayinda alamar za ta iya bayyana a matsayin bayani na binary na eh/aa, lambar ta ainihi tana samuwa ta hanyar daidaitawa
Mantisse * 2Exponent

Hakanan akwai wasu darajoji masu tsauri da ke rufe wasu lokuta na lambobin ruwaito - ciki har da ±∞ da NaN ("babu ingantaccen lamba").

Matsayin Gleitkomma yana da amfani musamman lokacin da daidaito ba shi da mahimmanci, saboda a wannan nau'in darajoji yana faruwa cewa za a sami kurakuran zagaye da kuma asarar daidaito. Yawanci, ana amfani da matsayi na Gleitkomma misali don bayyana ko'odinate, kamar vertex vectors a cikin samfurin 3D ko Bézier/Spline curves don dalilan wakilci na gani.

A cikin tsarin bayanai, ana bayyana matsayi na Gleitkomma a matsayin float(Mantisse, Exponent).
Idan an yi amfani da tsarin da ya bambanta da IEEE 754, ana bayyana hakan a bisa ga haka.