1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/openharmony-arkcompiler_ets_frontend

 / Детали:

[ArkTS frontend] Inconsistent behavior when bigint created from number

Завершенные
Владелец
Создано  
26.11.2024

Testing 3.8.13 Type BigInt and observing an inconsistent behavior when a bigint is created from number. Here is correctly working case:

function main() {
  let s: number = 0.000001  // 1e-6
  console.log(s)
  let b = new BigInt(s)
  console.log(b)
}

0.000001
[TID 26d4fe] E/runtime: Unhandled exception: escompat.Error
[TID 26d4fe] E/runtime: Error: Can't convert number 0.000001 to BigInt because it's not an integer
[TID 26d4fe] E/runtime:         at escompat.Error.<ctor> (<unknown>:1)
[TID 26d4fe] E/runtime:         at escompat.BigInt.parseFromString (<unknown>:1002)
[TID 26d4fe] E/runtime:         at escompat.BigInt.<ctor> (<unknown>:89)
[TID 26d4fe] E/runtime:         at escompat.BigInt.<ctor> (<unknown>:82)
[TID 26d4fe] E/runtime:         at ETSGLOBAL.main (/home/vkopyl/test5/test.ets:4)
[TID 26d4fe] E/runtime: 

If we set s to 1e-7, we see the following incorrect behavior, 1e-7 is accepted as 0:

function main() {
  let s: number = 0.0000001  // 1e-7
  console.log(s)
  let b = new BigInt(s)
  console.log(b)
}

1e-7
0

Комментарий (0)

GitLife Service Account Задача создана
GitLife Service Account добавлено
 
waiting_for_assign
label.
GitLife Service Account добавлено
 
异常关闭
label.
GitLife Service Account изменить Статус задачи с Предстоит сделать на Завершенные
Развернуть журнал операций

Вход Перед тем как оставить комментарий

Статус
Ответственный
Контрольная точка
Pull Requests
Связанные запросы на слияние могут быть закрыты после их объединения
Ветки
Дата начала   -   Крайний срок
-
Закрепить/Открепить
Приоритет
Участники(1)
1
https://api.gitlife.ru/oschina-mirror/openharmony-arkcompiler_ets_frontend.git
git@api.gitlife.ru:oschina-mirror/openharmony-arkcompiler_ets_frontend.git
oschina-mirror
openharmony-arkcompiler_ets_frontend
openharmony-arkcompiler_ets_frontend