slint icon indicating copy to clipboard operation
slint copied to clipboard

Add 64-bit integer type

Open Serein207 opened this issue 1 year ago • 1 comments

Because the integer data in json is very large, and we need to store such data in slint. Of course, using string storage is also a compromise, but such an implementation is not very convenient for directly operating integer numbers.

Serein207 avatar Oct 19 '24 12:10 Serein207

True. We could make int to be 64 bits. Or we could add a int64 or i64 type.

ogoffart avatar Oct 21 '24 07:10 ogoffart

I’d rather go for adding a new int64 type, since the extra memory overhead might not be acceptable for everyone.

For about a year and a half, I’ve been using a workaround where I combine two int values to create a u64, that I use in rust side

pub(crate) fn split_u64_into_i32s(value: u64) -> (i32, i32) {
    let part1: i32 = (value >> 32) as i32;
    let part2: i32 = value as i32;
    (part1, part2)
}

pub(crate) fn connect_i32_into_u64(part1: i32, part2: i32) -> u64 {
    ((part1 as u64) << 32) | (part2 as u64 & 0xFFFF_FFFF)
}

This makes operations on models a bit more cumbersome, so I’m also looking forward to having a new type added.

qarmin avatar Aug 09 '25 12:08 qarmin