SORU
6 NİSAN 2011, ÇARŞAMBA


C operatörleri örtülü tür dönüştürme kuralları

Kadroya ne zaman bilmek daha iyi olmak istiyorum. Eklerken C örtük tür dönüştürme kuralları ne, çarpma, vb. Örneğin,

int   float = ?
int * float = ?
float * int = ?
int / float = ?
float / int = ?
int / int = ?
int ^ float = ?

vesaire...

Bu ifade her zaman daha hassas türü olarak değerlendirilir? Kurallar Java için çok fark var mı? Eğer hatalı bu soru ifadeli varsa lütfen beni düzeltin.

CEVAP
6 NİSAN 2011, ÇARŞAMBA


C operatörleri (POD türleri için) hep aynı tür nesneleri hareket.
Eğer aynı değilse böylece bir başka maç tanıtılacak.
Operasyon sonucu tip işlenenler (dönüşüm sonra) aynıdır.

If either is      long          double the other is promoted to      long          double
If either is                    double the other is promoted to                    double
If either is                    float  the other is promoted to                    float
If either is long long unsigned int    the other is promoted to long long unsigned int
If either is long long          int    the other is promoted to long long          int
If either is long      unsigned int    the other is promoted to long      unsigned int
If either is long               int    the other is promoted to long               int
if either is           unsigned int    the other is promoted to           unsigned int
If either is                    int    the other is promoted to                    int
Both operands are promoted to int

Not. Operasyonların en küçük boyut int. Kısa/char işlemden önce int için teşvik edilmektedir.

Tüm ifadelerde int işlem yapılmadan önce bir şamandıra terfi etti. İşleminin sonucu bir şamandıra.

int   float =>  float   float = float
int * float =>  float * float = float
float * int =>  float * float = float
int / float =>  float / float = float
float / int =>  float / float = float
int / int                     = int
int ^ float =>  <compiler error>

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 8lacKy

    8lacKy

    30 Mart 2009
  • 10 Daughters, 2 Sons

    10 Daughters

    10 Mart 2009
  • The Onion

    The Onion

    14 Mart 2006