本文簡要介紹rust語言中 u16.log2
的用法。
用法
pub const fn log2(self) -> u32
返回數字的以 2 為底的對數,向下舍入。
Panics
當數字為負數或零時,它在調試模式下會發生Panics,在發布模式下返回值為 0。
例子
#![feature(int_log)]
assert_eq!(2u16.log2(), 1);
相關用法
- Rust u16.log10用法及代碼示例
- Rust u16.log用法及代碼示例
- Rust u16.leading_ones用法及代碼示例
- Rust u16.leading_zeros用法及代碼示例
- Rust u16.saturating_add用法及代碼示例
- Rust u16.rem_euclid用法及代碼示例
- Rust u16.from_le用法及代碼示例
- Rust u16.checked_mul用法及代碼示例
- Rust u16.checked_add用法及代碼示例
- Rust u16.saturating_add_signed用法及代碼示例
- Rust u16.unstable_div_floor用法及代碼示例
- Rust u16.count_zeros用法及代碼示例
- Rust u16.unstable_next_multiple_of用法及代碼示例
- Rust u16.checked_add_signed用法及代碼示例
- Rust u16.wrapping_neg用法及代碼示例
- Rust u16.saturating_pow用法及代碼示例
- Rust u16.overflowing_rem用法及代碼示例
- Rust u16.trailing_ones用法及代碼示例
- Rust u16.wrapping_pow用法及代碼示例
- Rust u16.checked_shr用法及代碼示例
- Rust u16.checked_shl用法及代碼示例
- Rust u16.borrowing_sub用法及代碼示例
- Rust u16.checked_neg用法及代碼示例
- Rust u16.saturating_div用法及代碼示例
- Rust u16.overflowing_add用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 u16.log2。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。