• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,057925

screenshots/device/12-May-2024-

.gitignoreD12-May-2024142 1111

README.mdD12-May-20241 KiB2412

README_zh.mdD12-May-20241.6 KiB4323

build-profile.json5D12-May-20241 KiB4341

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024381 1818

README.md

1# util Tool Function – RationalNumber
2
3### Introduction
4
5This sample shows how to use the **RationalNumber** function in the **util** class for rational number operations.
6
7### Usage
8
91. Touch **Compare rational numbers** to compare two rational numbers. The comparison result is displayed in the text box.
10
112. Touch **Get rational number value**. The integer or floating point value of the first rational number is displayed in the text box.
12
133. Touch **Get numerator and denominator**. The numerator and denominator of the rational number are displayed in the text box.
14
154. Touch **Check for zero** to check whether the rational number is **0**. The check result is displayed in the text box.
16
175. Touch **Check for NaN** to check whether the rational number is Not a Number (NaN). The check result is displayed in the text box.
18
196. Touch **Check for finite number** to check whether the rational number is a finite number. The check result is displayed in the text box.
20
21### Constraints
22
23This sample can only be run on standard-system devices.
24

README_zh.md

1# 有理数
2
3### 介绍
4
5[util](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-util.md)工具函数提供多种常用函数,如:实现字符串编解码、有理数运算、缓冲区管理、范围判断、Base64编解码、内置对象类型检查等。
6
7本示例使用[util](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-util.md)中RationalNumber相关接口实现有理数运算,展示了util工具类中的有理数运算的一些方法使用。
8
9使用说明:
10
111.点击按钮“**有理数比较**”,对两个有理数进行比较,比较结果会在文本框中显示。
12
132.点击按钮“**获取有理数的值**”,将在文本框中显示第一个有理数的整数或浮点型的值。
14
153.点击按钮“**获取有理数分子分母**”,在文本框中显示有理数的分子分母。
16
174.点击按钮“**检查是否为0**”,在文本框中显示判断有理数是否为0的结果。
18
195.点击按钮“**检查是否表示NaN**”,在文本框中显示判断有理数是否为非数字结果。
20
216.点击按钮“**检查是否为有限值**”,在文本框中显示有理数是否为有限值结果。
22
23### 效果预览
24
25|主页|
26|--------------------------------|
27|![](./screenshots/device/eTSRationalNumber.png)|
28
29### 相关权限
30
31不涉及。
32
33### 依赖
34
35不涉及。
36
37### 约束与限制
38
391.本示例仅支持在标准系统上运行。
40
412.本示例仅支持API9版本SDK,版本号:3.2.10.6。
42
433.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。