Created
April 11, 2025 12:46
-
-
Save kaineer/f925a33168ad2320834baafc429c66cc to your computer and use it in GitHub Desktop.
integer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const displayWidth = 8; | |
const maxInt = parseInt("9".repeat(displayWidth)); | |
const minInt = parseInt("-" + "9".repeat(displayWidth - 1)); | |
const wrongValue = new RuntimeError('некорректное значение'); | |
const wrongOperation = new RuntimeErr('некорректная операция (переполнение)') | |
const createInteger = (string) => { | |
const value = parseInt(string); | |
let error = null; | |
if (Number.isInteger(value)) { | |
} else { | |
error = wrongValue; | |
} | |
return { | |
val: value, | |
} | |
} | |
const createRegister = ({ | |
writeable = true, | |
readable = true, | |
} = {}) => { | |
return { | |
get writeable() { | |
return writeable; | |
}, | |
get readable() { | |
return readable; | |
} | |
} | |
} | |
const createWORegister = () => createRegister({ writeable: true, readable: false }); | |
const createRORegister = () => createRegister({ readable: true, writeable: false }); | |
createRegister.RO = createRORegister; | |
createRegister.WO = createWORegister; | |
const reg = createRegister.RO(); | |
console.log(reg.writeable); | |
console.log(reg.readable); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment