js base number All In One
js base number All In One
js 进制数
class UFO {
public name: string = '';
private id?: number = 0;
constructor(name: string, id?: number) {
this.name = name;
if (id) {
this.id = id;
}
}
protected getName() {
console.log(`UFO name = ${this.name}`);
}
getId() {
console.log('UFO id =', this.id);
}
getAll() {
this.getName();
this.getId();
}
}
// const ufo = new UFO('ufo', 007);
/*
Octal literals are not allowed in strict mode.ts(1121)
Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '0o7'.ts(1085)
*/
const ufo = new UFO('ufo', 7);
const ufo_binary = new UFO('ufo', 0b111);
const ufo_octal = new UFO('ufo', 0o007);
const ufo_hex = new UFO('ufo', 0x007);
ufo.name;
ufo.getId();
// ufo.getName();
// Property 'getName' is protected and only accessible within class 'UFO' and its subclasses.ts(2445)
ufo.getAll();
Binary number
二进制数
0~1
var FLT_SIGNBIT = 0b10000000000000000000000000000000; // 2147483648
var FLT_EXPONENT = 0b01111111100000000000000000000000; // 2139095040
var FLT_MANTISSA = 0B00000000011111111111111111111111; // 8388607
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#binary
Octal number
八进制数
0~7
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#octal
Hexadecimal number
十六进制数
0~F
0xFFFFFFFFFFFFFFFFF;
// 295147905179352830000
0x123456789ABCDEF;
// 81985529216486900
0XA;
// 10
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#hexadecimal
BigInt literal
123456789123456789n;
// 123456789123456789
0o777777777777n;
// 68719476735
0x123456789ABCDEFn;
// 81985529216486895
0b11101001010101010101n;
// 955733
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#bigint_literal
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type
refs
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/15866634.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2020-02-06 Google 灭霸 彩蛋
2020-02-06 POST 非幂等 All In One