René's URL Explorer Experiment


Title: BigDecimal文档里,建议对保留规则设置为ROUND_HALF_EVEN · Issue #2129 · Snailclimb/JavaGuide · GitHub

Open Graph Title: BigDecimal文档里,建议对保留规则设置为ROUND_HALF_EVEN · Issue #2129 · Snailclimb/JavaGuide

X Title: BigDecimal文档里,建议对保留规则设置为ROUND_HALF_EVEN · Issue #2129 · Snailclimb/JavaGuide

Description: 文档里BigDecimalUtil类选择的保留规则是RoundingMode.HALF_UP,即四舍五入。代码部分如下: /** * 提供精确的小数位四舍五入处理。 * * @param v 需要四舍五入的数字 * @param scale 小数点后保留几位 * @return 四舍五入后的结果 */ public static double round(double v, int scale) { if (scale < 0) { throw new IllegalA...

Open Graph Description: 文档里BigDecimalUtil类选择的保留规则是RoundingMode.HALF_UP,即四舍五入。代码部分如下: /** * 提供精确的小数位四舍五入处理。 * * @param v 需要四舍五入的数字 * @param scale 小数点后保留几位 * @return 四舍五入后的结果 */ public static double round(double v, int scal...

X Description: 文档里BigDecimalUtil类选择的保留规则是RoundingMode.HALF_UP,即四舍五入。代码部分如下: /** * 提供精确的小数位四舍五入处理。 * * @param v 需要四舍五入的数字 * @param scale 小数点后保留几位 * @return 四舍五入后的结果 */ public static double round(double v, int scal...

Opengraph URL: https://github.com/Snailclimb/JavaGuide/issues/2129

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"BigDecimal文档里,建议对保留规则设置为ROUND_HALF_EVEN","articleBody":"文档里BigDecimalUtil类选择的保留规则是`RoundingMode.HALF_UP`,即四舍五入。代码部分如下:\r\n```\r\n/**\r\n     * 提供精确的小数位四舍五入处理。\r\n     *\r\n     * @param v     需要四舍五入的数字\r\n     * @param scale 小数点后保留几位\r\n     * @return 四舍五入后的结果\r\n     */\r\n    public static double round(double v, int scale) {\r\n        if (scale \u003c 0) {\r\n            throw new IllegalArgumentException(\r\n                    \"The scale must be a positive integer or zero\");\r\n        }\r\n        BigDecimal b = BigDecimal.valueOf(v);\r\n        BigDecimal one = new BigDecimal(\"1\");\r\n        return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();\r\n    }\r\n```\r\n建议修改为`BigDecimal.ROUND_HALF_EVEN`,也就是`RoundingMode.HALF_EVEN`,即四舍六入五成双(为什么会发现:做项目时发现不同的写法,去查资料看了)。\r\n![Snipaste_2023-08-10_21-12-40](https://github.com/Snailclimb/JavaGuide/assets/37408772/9bcdf760-b4c1-4b0e-806d-3295e45d173c)\r\n我就把百度的四舍六入五成双规则贴过来了:\r\n对于位数很多的近似数,当有效位数确定后,其后面多余的数字应该舍去,只保留有效数字最末一位,这种修约(舍入)规则是“四舍六入五成双”,也即“4舍6入5凑偶”,这里“四”是指≤4 时舍去,\"六\"是指≥6时进上,\"五\"指的是根据5后面的数字来定,当5后有数时,舍5入1;当5后无有效数字时,需要分两种情况来讲:\r\n(1)5前为奇数,舍5入1;\r\n(2)5前为偶数,舍5不进(0是偶数)。\r\n推荐使用四舍六入五成双规则的原因:\r\n从统计学的角度,“四舍六入五成双”比“四舍五入”要科学,在大量运算时,它使舍入后的结果误差的均值趋于零,而不是像四舍五入那样逢五就入,导致结果偏向大数,使得误差产生积累进而产生系统误差,“四舍六入五成双”使测量结果受到舍入误差的影响降到最低。\r\n\r\n\r\n","author":{"url":"https://github.com/sunquan123","@type":"Person","name":"sunquan123"},"datePublished":"2023-08-10T13:15:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/2129/JavaGuide/issues/2129"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:315c88ec-ea8a-e477-038a-08fdcd338bd8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD32E:198E4:3DFEC96:58048F3:6A56AA1A
html-safe-nonced90ab60a0e9c376d7f3a8611b45cdddd0137be4612c67cb04f6ae2b3db1b2443
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzJFOjE5OEU0OjNERkVDOTY6NTgwNDhGMzo2QTU2QUExQSIsInZpc2l0b3JfaWQiOiI1MTI4NjgwODc1ODMyNTUxOTYyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4ceac2c913b6c37c08e3f08bdb51585c7af62d2c3b6ccf55b6f8856935bf52a5
hovercard-subject-tagissue:1845170641
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Snailclimb/JavaGuide/2129/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b4208c8a6a89609a4d5f8e6a7d5918aa623b8968028a821045b80a9a5ed497fa/Snailclimb/JavaGuide/issues/2129
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b4208c8a6a89609a4d5f8e6a7d5918aa623b8968028a821045b80a9a5ed497fa/Snailclimb/JavaGuide/issues/2129
og:image:alt文档里BigDecimalUtil类选择的保留规则是RoundingMode.HALF_UP,即四舍五入。代码部分如下: /** * 提供精确的小数位四舍五入处理。 * * @param v 需要四舍五入的数字 * @param scale 小数点后保留几位 * @return 四舍五入后的结果 */ public static double round(double v, int scal...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesunquan123
hostnamegithub.com
expected-hostnamegithub.com
None13efe7fe8ecc41eda1078cbde8206041ed92bc54e29bcb737e9353dd9c407aad
turbo-cache-controlno-preview
go-importgithub.com/Snailclimb/JavaGuide git https://github.com/Snailclimb/JavaGuide.git
octolytics-dimension-user_id29880145
octolytics-dimension-user_loginSnailclimb
octolytics-dimension-repository_id132464395
octolytics-dimension-repository_nwoSnailclimb/JavaGuide
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id132464395
octolytics-dimension-repository_network_root_nwoSnailclimb/JavaGuide
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5466ebe023a0abf876a1e6c5d7602ee8f5e6a02b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/Snailclimb/JavaGuide/issues/2129#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSnailclimb%2FJavaGuide%2Fissues%2F2129
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FSnailclimb%2FJavaGuide%2Fissues%2F2129
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=Snailclimb%2FJavaGuide
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/2129
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/2129
Reloadhttps://github.com/Snailclimb/JavaGuide/issues/2129
Snailclimb https://github.com/Snailclimb
JavaGuidehttps://github.com/Snailclimb/JavaGuide
Notifications https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Fork 46.2k https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Star 157k https://github.com/login?return_to=%2FSnailclimb%2FJavaGuide
Code https://github.com/Snailclimb/JavaGuide
Issues 57 https://github.com/Snailclimb/JavaGuide/issues
Pull requests 1 https://github.com/Snailclimb/JavaGuide/pulls
Discussions https://github.com/Snailclimb/JavaGuide/discussions
Actions https://github.com/Snailclimb/JavaGuide/actions
Projects https://github.com/Snailclimb/JavaGuide/projects
Security and quality 0 https://github.com/Snailclimb/JavaGuide/security
Insights https://github.com/Snailclimb/JavaGuide/pulse
Code https://github.com/Snailclimb/JavaGuide
Issues https://github.com/Snailclimb/JavaGuide/issues
Pull requests https://github.com/Snailclimb/JavaGuide/pulls
Discussions https://github.com/Snailclimb/JavaGuide/discussions
Actions https://github.com/Snailclimb/JavaGuide/actions
Projects https://github.com/Snailclimb/JavaGuide/projects
Security and quality https://github.com/Snailclimb/JavaGuide/security
Insights https://github.com/Snailclimb/JavaGuide/pulse
BigDecimal文档里,建议对保留规则设置为ROUND_HALF_EVENhttps://github.com/Snailclimb/JavaGuide/issues/2129#top
enhancementNew feature or request or suggestionhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/sunquan123
sunquan123https://github.com/sunquan123
on Aug 10, 2023https://github.com/Snailclimb/JavaGuide/issues/2129#issue-1845170641
https://private-user-images.githubusercontent.com/37408772/259752224-9bcdf760-b4c1-4b0e-806d-3295e45d173c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODQwNjQ4MzksIm5iZiI6MTc4NDA2NDUzOSwicGF0aCI6Ii8zNzQwODc3Mi8yNTk3NTIyMjQtOWJjZGY3NjAtYjRjMS00YjBlLTgwNmQtMzI5NWU0NWQxNzNjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA3MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNzE0VDIxMjg1OVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3ZmE3ZDQwNmJiMGJjZWNmZjIzZDhiNGMzOGMwOTYzYzU5Y2YyYzgxNTEwMDJhOGFjNzQzYmUzMjQ1YzIzOTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JnJlc3BvbnNlLWNvbnRlbnQtdHlwZT1pbWFnZSUyRnBuZyJ9.N2GMXPFHp74In_wCqdoM3kdWlyqnrPROYNd7giGbDhM
enhancementNew feature or request or suggestionhttps://github.com/Snailclimb/JavaGuide/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.