大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> 函数小数转分数,限于整除分数

函数小数转分数,限于整除分数

时间: 2021-07-31 作者:daque

'因变量实行少量转分数public function xtof(str as currency, optional fenm as integer = 32) as string '限于于整除分数 dim cfm as currency dim cfmmod as integer on error goto erroreof cfm = 1 / fenm xtof = "" if str = 0 then xtof = "": exit function dim point as integer dim dint as string dim dpoint as currency dim fint, fint1, fint2 as integer if str <> 0 then if str > 1 then point = instr(1, str, ".", 1) if point = 0 then xtof = str: exit function else dint = mid(str, 1, point - 1) dpoint = ccur("0." & mid(str, point + 1)) fint = instr(1, xtof(dpoint), "/", 1) fint1 = cint(mid(xtof(dpoint), 1, fint - 1)) fint2 = cint(mid(xtof(dpoint), fint + 1)) xtof = cstr(dint * fint2 + fint1) & "/" & cstr(fint2) end if else if fenm mod cint(str / cfm) = 0 then xtof = "1/" + cstr(fenm / cint(str / cfm)) else cfmmod = maxgys(fenm, cint(str / cfm)) xtof = cstr(cint(str / cfm / cfmmod)) + "/" + cstr(cint(fenm / cfmmod)) end if end if else xtof = "0" end if exit functionerroreof: xtof = ""end functionfunction maxgys(num1 as integer, num2 as integer) as integer dim minnum, i as integer minnum = num1 if num1 > num2 then minnum = num2 for i = 1 to minnum if ((num1 mod i) = 0) and ((num2 mod i) = 0) then maxgys = i next iend function

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.