MVC4和Simplemembership(MVC4 and Simplemembership)
我有点像新手应用程序开发人员,对于MVC4来说当然是非常新的,并且已经通过一些方便的教程来学习MVC的核心原理。 我确实迷失了作为entirley自学的人的术语。
我正在尝试替换我之前编写的使用ASP.net成员资格的应用程序,我可以自己创建。 此应用程序是一个问题日志记录和报告系统,它可以对SQL数据库执行大量操作。
我不关心在新的simplemembership提供程序中删除所有用户并重建用户数据库。 虽然,我不知道从哪里开始。
我觉得好像使用现成的“互联网应用程序”模板意味着我最终得到了我不需要(或理解)的大量文件/文件夹,所以我的问题是,如何从MVC4和简单的成员开始,理想情况下不使用“互联网应用”模板。
谢谢。
I am somewhat of a novice application developer, certainly very new to MVC4 and have been through a number of handy tutorials to learn the core principles of MVC. I do get lost with terminology as someone who is entirley self taught.
I am trying to replace an application I wrote previously that uses ASP.net membership which I was able to create myself. This application is an issue logging and reporting system that does a lot with an SQL database.
I have no concern dropping all the users and rebuilding the user database in the new simplemembership provider. Although, I am not sure where to start.
I feel as though using the ready made "internet application" template means I end up with loads of files / folders I do not need (or understand), so my question is, how to I start with MVC4 and simplemembership, ideally without using the "internet application" template.
Thank you.
原文:https://stackoverflow.com/questions/19010372
最满意答案
从那里交叉: https : //codereview.stackexchange.com/questions/24299/is-this-the-way-of-truncating-the-fractional-part-of-a-bigdecimal-when-its-scale
这可能吗? 什么是最好的办法?
可能
stripTrailingZeros()
。检查你的测试:
public static void main(final String[] args) { check(truncate("12.000000"), "12"); check(truncate("12.0001"), "12"); check(truncate("12.0051"), "12.01"); check(truncate("12.99"), "12.99"); check(truncate("12.999"), "13"); check(truncate("12.3456"), "12.35"); System.out.println("if we see this message without exceptions, everything is ok"); } private static BigDecimal truncate(final String text) { BigDecimal bigDecimal = new BigDecimal(text); if (bigDecimal.scale() > 2) bigDecimal = new BigDecimal(text).setScale(2, RoundingMode.HALF_UP); return bigDecimal.stripTrailingZeros(); } private static void check(final BigDecimal bigDecimal, final String string) { if (!bigDecimal.toString().equals(string)) throw new IllegalStateException("not equal: " + bigDecimal + " and " + string); }
输出:
如果我们看到此消息没有例外,那么一切都可以
For the crosslink from there: https://codereview.stackexchange.com/questions/24299/is-this-the-way-of-truncating-the-fractional-part-of-a-bigdecimal-when-its-scale
Is this possible? What is the best way to do?
Probably
stripTrailingZeros()
.To check your tests:
public static void main(final String[] args) { check(truncate("12.000000"), "12"); check(truncate("12.0001"), "12"); check(truncate("12.0051"), "12.01"); check(truncate("12.99"), "12.99"); check(truncate("12.999"), "13"); check(truncate("12.3456"), "12.35"); System.out.println("if we see this message without exceptions, everything is ok"); } private static BigDecimal truncate(final String text) { BigDecimal bigDecimal = new BigDecimal(text); if (bigDecimal.scale() > 2) bigDecimal = new BigDecimal(text).setScale(2, RoundingMode.HALF_UP); return bigDecimal.stripTrailingZeros(); } private static void check(final BigDecimal bigDecimal, final String string) { if (!bigDecimal.toString().equals(string)) throw new IllegalStateException("not equal: " + bigDecimal + " and " + string); }
output:
if we see this message without exceptions, everything is ok
相关问答
更多-
测试BigDecimal是否可以改变其他BigDecimal的组成部分(Test if BigDecimal can change integral part of other BigDecimal)[2022-04-05]
你可以这样做: BigDecimal b1 = new BigDecimal("0.90"); BigDecimal b2 = new BigDecimal("0.20"); if(b1.add(b2).intValue() > Math.max(b1.intValue(), b2.intValue())){ System.out.println("The integral has changed"); }else { System.out.println("The integral is ... -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
java.math.BigDecimal.scale()等效于double(java.math.BigDecimal.scale() equivalent for double)[2023-01-22]
BigDecimal.scale()方法不会像您认为的那样做。 BigDecimal值存储为a * 10^b (其中^表示取幂)。 BigDecimal.scale()方法基本上返回b部分。 我不知道double值的类似方法,也不知道执行所需功能的方法。 由于您在标记中放置了apache-commons,因此我建议您查看Apache Commons的扩展统计库。 The BigDecimal.scale() method does not do what you seem to think it is do ... -
我会尝试bd.remainder(BigDecimal.ONE) 。 使用remainder法和ONE常数。 BigDecimal bd = new BigDecimal( "23452.4523434" ); BigDecimal fractionalPart = bd.remainder( BigDecimal.ONE ); // Result: 0.4523434 I would try bd.remainder(BigDecimal.ONE). Uses the remainder method ...
-
BigDecimal乘以零(BigDecimal multiply by zero)[2022-04-27]
你不能使用equals()方法来比较BigDecimals ,就像这个断言一样。 这是因为这等于功能将比较比例 。 如果比例不同,则equals()将返回false,即使它们是数学上相同的数字。 但是您可以使用compareTo()来执行所需的操作: 正如@assylias指出的,你也应该使用new BigDecimal("22.3")构造函数来避免双重精度问题。 BigDecimal expected = BigDecimal.ZERO; BigDecimal actual = new BigDecima ... -
从那里交叉: https : //codereview.stackexchange.com/questions/24299/is-this-the-way-of-truncating-the-fractional-part-of-a-bigdecimal-when-its-scale 这可能吗? 什么是最好的办法? 可能stripTrailingZeros() 。 检查你的测试: public static void main(final String[] args) { check(truncat ...
-
得到BigDecimal的指数(Get exponent of a BigDecimal)[2023-01-09]
(defn exp<-bigdec "Returns the exponent, b, from a BigDecimal in the form a * 10 ^ b." [x] (- (.precision x) (.scale x) 1)) (defn exp<-bigdec "Returns the exponent, b, from a BigDecimal in the form a * 10 ^ b." [x] (- (.precision x) (.scale x) ... -
这是因为代表性问题。 实际值123.1111d可以是123.111091231918498。 这就是为什么当你想要精确的值时,建议使用字符串构造函数。 This is because of representation problem. The value 123.1111d in reality can be something like 123.111091231918498. That why it is recommended to use string constructor when you w ...
-
javadoc说...... 抛出: ArithmeticException - 如果divisor == 0,或者roundingMode == ROUND_UNNECESSARY,this.scale()不足以完全表示除法的结果。 因此,如果scale()不够,则会发生ArithmeticException ,这个假设似乎是正确的 ; 即余数不为零。 The javadoc says... Throws: ArithmeticException - if divisor==0, or roundingM ...
-
Java BigDecimal行为(Java BigDecimal Behaviour)[2022-02-01]
如果我了解你,你就错过了setScale()的结果。 d = d.setScale(4); 编辑 至于你的第二个问题,你可以调用stripTrailingZeros() - d = d.stripTrailingZeros(); If I understand you, you've missed the assignment from the result of setScale(); d = d.setScale(4); Edit As for your second question, you ...