✨ feat(App.vue): 添加 `getMaxNumber` 函数,用于计算最大无符号数字
This commit is contained in:
parent
4774ddea6f
commit
032e8d694d
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
{{ selectIndex }}
|
从 M{{ selectIndex }}.0 开始,占用 {{ selectIndexWidth + 1 }} 个 Byte,最大可以表示无符号数字 {{ (selectIndexWidth + 1) * 8 }}
|
||||||
|
{{ getMaxNumber() }}
|
||||||
<button @click="selectIndexWidth = 0">
|
<button @click="selectIndexWidth = 0">
|
||||||
<span v-show="selectIndexWidth == 0">激活=></span>MB</button>
|
<span v-show="selectIndexWidth == 0">激活=></span>MB</button>
|
||||||
<button @click="selectIndexWidth = 1">
|
<button @click="selectIndexWidth = 1">
|
||||||
|
@ -29,6 +30,11 @@ function getClassName(i) {
|
||||||
if (Math.min(min, i) === min && Math.max(max, i) === max) return 'select'
|
if (Math.min(min, i) === min && Math.max(max, i) === max) return 'select'
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMaxNumber() {
|
||||||
|
const bin = '1'.repeat((selectIndexWidth.value + 1) * 8)
|
||||||
|
return Number.parseInt(bin, 2)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
Reference in New Issue