mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
commit
83d9ab3ba5
13 changed files with 103 additions and 97 deletions
|
@ -111,19 +111,19 @@ pub fn transform_text(text: &str,
|
|||
}
|
||||
}
|
||||
|
||||
pub fn float_to_fixed(before: int, f: f64) -> i32 {
|
||||
((1i32 << before as uint) as f64 * f) as i32
|
||||
pub fn float_to_fixed(before: usize, f: f64) -> i32 {
|
||||
((1i32 << before) as f64 * f) as i32
|
||||
}
|
||||
|
||||
pub fn fixed_to_float(before: int, f: i32) -> f64 {
|
||||
f as f64 * 1.0f64 / ((1i32 << before as uint) as f64)
|
||||
pub fn fixed_to_float(before: usize, f: i32) -> f64 {
|
||||
f as f64 * 1.0f64 / ((1i32 << before) as f64)
|
||||
}
|
||||
|
||||
pub fn fixed_to_rounded_int(before: int, f: i32) -> int {
|
||||
let half = 1i32 << (before-1) as uint;
|
||||
pub fn fixed_to_rounded_int(before: isize, f: i32) -> isize {
|
||||
let half = 1i32 << (before-1) as usize;
|
||||
if f > 0i32 {
|
||||
((half + f) >> before as uint) as int
|
||||
((half + f) >> before) as isize
|
||||
} else {
|
||||
-((half - f) >> before as uint) as int
|
||||
-((half - f) >> before) as isize
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue