Calling Functions A Tutorial
chooses the best available option: 1. Exact/identity match 2. Trivial conversion 3. Promotion 4. Promotion + trivial conversion 5. Standard conversion 6. Standard conversion + trivial conversion 1)Promotions (Rank 2) 62 The following standard conversions count as promotions: • Integral promotion • unsigned short ➜ unsigned int or int (depending on your platform) • short ➜ int • char ➜ int point promotion • float ➜ doublePromotions (Rank 2) 63 void f( int ); // (1) void f( double ); // (2) int main() { short v = 42; f( v ); } // Calls (1) (integral promotion, rank0 码力 | 111 页 | 5.11 MB | 5 月前3Back to Basics - Function Call Resolution
put(int c, FILE *f); In each case, the compiler promotes charto intto achieve the match. That promotion may generate additional code that executes at run time. 15 Best Matches and Ambiguities In “cheap” array-to-pointer conversion qualification conversion etc. integral promotion Promotion floating-point promotion integral conversion Conversion “expensive” floating-point conversion pointer “cheap” array-to-pointer conversion qualification conversion etc. integral promotion Promotion floating-point promotion integral conversion Conversion “expensive” floating-point conversion pointer0 码力 | 44 页 | 1.30 MB | 5 月前3Julia v1.6.6 Documentation
. . . 152 14 Conversion and Promotion 154 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.2 Promotion . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 9 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS 10 Type Precision Number of bits Float16 Once created, they participate in arithmetic with all other numeric types thanks to Julia's type promotion and conversion mechanism: julia> BigInt(typemax(Int64)) + 1 9223372036854775808 julia> big"0 码力 | 1324 页 | 4.54 MB | 1 年前3Julia 1.6.5 Documentation
. . . 152 14 Conversion and Promotion 154 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.2 Promotion . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 9 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS 10 Type Precision Number of bits Float16 Once created, they participate in arithmetic with all other numeric types thanks to Julia's type promotion and conversion mechanism: julia> BigInt(typemax(Int64)) + 1 9223372036854775808 julia> big"0 码力 | 1325 页 | 4.54 MB | 1 年前3Julia 1.6.7 Documentation
. . . 152 14 Conversion and Promotion 154 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.2 Promotion . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 9 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS 10 Type Precision Number of bits Float16 Once created, they participate in arithmetic with all other numeric types thanks to Julia's type promotion and conversion mechanism: julia> BigInt(typemax(Int64)) + 1 9223372036854775808 julia> big"0 码力 | 1324 页 | 4.54 MB | 1 年前3Julia 1.6.1 Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14 Conversion and Promotion 161 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.2 Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Defining Promotion Rules . . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 11 12 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS Type Precision Number of bits Float160 码力 | 1397 页 | 4.59 MB | 1 年前3Julia 1.6.4 Documentation
. . . 152 14 Conversion and Promotion 154 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.2 Promotion . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 9 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS 10 Type Precision Number of bits Float16 Once created, they participate in arithmetic with all other numeric types thanks to Julia's type promotion and conversion mechanism: julia> BigInt(typemax(Int64)) + 1 9223372036854775808 julia> big"0 码力 | 1324 页 | 4.54 MB | 1 年前3Julia 1.7.0 DEV Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 14 Conversion and Promotion 163 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 14.2 Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Defining Promotion Rules . . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 11 12 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS Type Precision Number of bits Float160 码力 | 1399 页 | 4.59 MB | 1 年前3Julia 1.6.0 DEV Documentation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14 Conversion and Promotion 161 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.2 Promotion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 Defining Promotion Rules . . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 11 12 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS Type Precision Number of bits Float160 码力 | 1383 页 | 4.56 MB | 1 年前3Julia 1.6.2 Documentation
. . . 152 14 Conversion and Promotion 154 14.1 Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.2 Promotion . . . . . . . . . . . . . . . types interoperate naturally without explicit casting, thanks to a flexible, user-extensible type promotion system. 9 CHAPTER 4. INTEGERS AND FLOATING-POINT NUMBERS 10 Type Precision Number of bits Float16 Once created, they participate in arithmetic with all other numeric types thanks to Julia's type promotion and conversion mechanism: julia> BigInt(typemax(Int64)) + 1 9223372036854775808 julia> big"0 码力 | 1324 页 | 4.54 MB | 1 年前3
共 231 条
- 1
- 2
- 3
- 4
- 5
- 6
- 24