当前位置: 肆参拓扑网 > 知识问答 > oracle round函数是什么意思?怎么运用?

oracle round函数是什么意思?怎么运用?

时间:2024-07-04 04:48:10来源:肆参拓扑网

oracle

round

函数指:传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果。

用法:

select

round(

number,

[

decimal_places

]

)

from

dual

参数:

number

:

欲处理之数值

decimal_places

:

四舍五入

,

小数取几位

(

预设为

)

具体案例:

a、select

round(160/3,3)

from

dual;

-----结果

53.33

b、select

round(160/3,1)

from

dual;

-----结果

53.3

c、select

round(160/3,0)

from

dual;

-----结果

53

d、select

round(160/3,-1)

from

dual;

-----结果

50

e、select

round(160/3,-2)

from

dual;

-----结果

100

扩展资料

关于trunc

和round函数比较

整体概括:

round函数指四舍五入。

trunc函数指直接截取。

对于时间:round函数对日期进行“四舍五入”,trunc函数对日期进行截取。如果我们不指定格式的话,round会返回一个最接近date参数的日期,而trunc函数只会简单的截取时分秒部分,返回年月日部分。

对于数字:round函数对数字同样进行“四舍五入”,trunc函数截取时不进行四舍五入,可以指明保留小数点后面的位数。

参考资料来源:搜狗百科—round

(函数)

round函数为oracle中的四舍五入函数。运用的方法是round(number,[decimals])

其中:number

待做四舍五入处理的数值,decimals

指明需保留小数点后面的位数。可选项,忽略它则保留0位小数,精确到个位;为负数,表示为小数点左边四舍五入处理。

示例如下:

sql>

select

round(123.123),

2

round(123.123,2),

3

round(123.16,2),

4

round(123.14,-2),

5

round(163.14,-2)

6

from

dual;

round(123.123)

round(123.123,2)

round(123.16,2)

round(123.14,-2)

round(163.14,-2)

123

123.12

123.16

100

200

扩展资料

excel中的round函数用法

round(number,decimals)

number是要舍入的数,decimals是指定的保留小数的位数。

decimals的取值可为正数,0,负数。当decimals的值为正数时,针对小数点后的数据进行四舍五入;当decimals的值为0时,返回最接近number的整数;当decimals的值为负数时,针对小数点前的数据进行四舍五入,被舍掉的数据用0占位。

示例如下:

round(123.456,2)

返回结果为:123.46

round(123.456,0)

返回结果为:123

round(123.456,-2)

返回结果为:100

参考资料:百度百科——round

oracle

round

函数的意思是四舍五入的方法,即传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果。

oracle

round

函数使用示例如下:

select

round(

number,

[

decimal_places

]

)

from

dual

1、参数 number

是指需要处理的数值,是必须填写的值。

2、参数

decimal_places

是指在进行四舍五入运算时

,

小数的应取的位数,该参数可以不填,不填的时候,系统默认小数位数取0。

3、函数应用举例:

①“select

round(988.211,

0)

from

dual;”得到结果为:988

②“select

round(988.211,

1)

from

dual;”得到结果为:988.2

③“select

round(988.211,

2)

from

dual;”

得到结果为:988.21

④“select

round(988.211,

3)

from

dual;”

得到结果为:988.211

⑤“select

round(-988.211,

2)

from

dual;”得到结果为:-988.21

扩展资料:

四舍五入是一种精确度的计数保留法,与其他方法本质相同。

但特殊之处在于采用四舍五入,能使被保留部分的与实际值差值不超过最后一位数量级的二分之一,假如0~9等概率出现的话,对大量的被保留数据,这种保留法的误差总和是最小的。

这也是我们使用这种方法为基本保留法的原因。

参考资料:搜狗百科-round函数搜狗百科-四舍五入

oracle

round

函数

(四舍五入),是指传回一个数值,该数值是按照指定的小数位元数进行四舍五入运算的结果。

使用方法

select

round(

number,

[

decimal_places

]

)

from

dual

其中number

为待做截取处理的数值。

decimals

指明需保留小数点后面的位数。可选项,忽略它则截去所有的小数部分,并四舍五入。如果为负数则表示从小数点开始左边的位数,相应整数数字用0填充,小数被去掉。需要注意的是,和trunc函数不同,对截取的数字要四舍五入。

参数:

number

:

欲处理之数值

decimal_places

:

四舍五入

,

小数取几位

(

预设为

)

sample

:

select

round(123.456,

0)

from

dual;

-----回传

123

select

round(123.456,

1)

from

dual;-----回传

123.5

select

round(123.456,

2)

from

dual;

-----回传

123.46

select

round(123.456,

3)

from

dual;

-----回传

123.456

扩展资料

matlab函数简介

调用格式:y

=

round(x)

在matlab中round也是一个四舍五入函数。在matlab的命令窗口中输入doc

round或者he**

round即可获得该函数的相关帮助信息。

程序示例

>>a

=

[-1.9,-0.2,3.4,5.6,7.0,2.4+3.6i]

a

=

columns

1

through

4

-1.9000

-0.2000

3.4000

5.6000

columns

5

through

6

⒎0000

2.4000

+

3.6000i

>>round(a)

ans

=

columns

1

through

4

-2.0000

3.0000

6.0000

columns

5

through

6

⒎0000

2.0000

+

4.0000i

a

=

columns

1

through

4

-1.9000

-0.2000

3.4000

5.6000

columns

5

through

6

⒎0000

2.4000

+

3.6000i

参考资料:百度百科-round函数

oracle中round函数是用于对数字进行截取操作,且会对截取的数字进行四舍五入运算。

oracle中round函数的应用:

语法为round(number,num_digits)

其中number是需要进行四舍五入的数字;num_digits为指定的位数,按此位数进行四舍五入,

如果

num_digits

大于

0,则四舍五入到指定的小数位,如果

num_digits

等于

0,

则四舍五入到最接近的整数,如果

num_digits

小于

0,则在小数点左侧进行四舍五入。

扩展资料:

oracle中trunc函数:

trunc函数是返回x按精度y截取后的值

trunc(x[,y])

,x,y,数字型表达式,如果y不为整数则截取y整数部分,如果y>0则截取到y位小数,如果y小于0则截取到小数点向左第y位,小数前其它数据用0表示。

例如:select

trunc(5555.66666,2.1),trunc(5555.66666,-2.6),trunc(5555.033333)

from

dual;

返回:5555.66

5500

5555

相似性:

round(x[,y])

返回截取后的值,用法同trunc(x[,y]),只是要做四舍五入。

参考资料来源:搜狗百科-round函数

免责声明:文章数据由网友投稿或转载,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请与本站管理员联系,我们将在第一时间删除内容!
Copyright ©2020-2024 肆参拓扑网 (www.43tp.com) 版权所有 琼ICP备2022010180号-11