Example usage for java.lang Float equals

List of usage examples for java.lang Float equals

Introduction

In this page you can find the example usage for java.lang Float equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object against the specified object.

Usage

From source file:Main.java

public static void main(String[] args) {
    Float obj1 = new Float("10");
    Float obj2 = new Float("10.0");
    System.out.print(obj1 + " = " + obj2);
    System.out.println(" ?  " + obj1.equals(obj2));

    obj1 = new Float("20");
    obj2 = new Float("6.000000");
    System.out.print(obj1 + " = " + obj2);
    System.out.println(" ?  " + obj1.equals(obj2));
}

From source file:NumberDemo.java

public static void main(String args[]) {
    Float one = new Float(14.78f - 13.78f);
    Float oneAgain = Float.valueOf("1.0");
    Double doubleOne = new Double(1.0);

    int difference = one.compareTo(oneAgain);

    if (difference == 0) {
        System.out.println("one is equal to oneAgain.");
    } else if (difference < 0) {
        System.out.println("one is less than oneAgain.");
    } else if (difference > 0) {
        System.out.println("one is greater than oneAgain.");
    }//  w ww .  j  a va 2  s .com

    System.out.println("one is " + ((one.equals(doubleOne)) ? "equal" : "not equal") + " to doubleOne.");

}

From source file:com.xqdev.jam.MLJAM.java

private static void sendXQueryResponse(HttpServletResponse res, Object o) throws IOException {
    // Make sure to leave the status code alone.  It defaults to 200, but sometimes
    // callers of this method will have set it to a custom code.
    res.setContentType("x-marklogic/xquery; charset=UTF-8");
    //res.setContentType("text/plain");
    Writer writer = res.getWriter(); // care to handle errors later?

    if (o == null) {
        writer.write("()");
    }//from  ww w  .  j  ava2 s .  co m

    else if (o instanceof byte[]) {
        writer.write("binary {'");
        writer.write(hexEncode((byte[]) o));
        writer.write("'}");
    }

    else if (o instanceof Object[]) {
        Object[] arr = (Object[]) o;
        writer.write("(");
        for (int i = 0; i < arr.length; i++) {
            sendXQueryResponse(res, arr[i]);
            if (i + 1 < arr.length)
                writer.write(", ");
        }
        writer.write(")");
    }

    else if (o instanceof String) {
        writer.write("'");
        writer.write(escapeSingleQuotes(o.toString()));
        writer.write("'");
    } else if (o instanceof Integer) {
        writer.write("xs:int(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Long) {
        writer.write("xs:integer(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Float) {
        Float flt = (Float) o;
        writer.write("xs:float(");
        if (flt.equals(Float.POSITIVE_INFINITY)) {
            writer.write("'INF'");
        } else if (flt.equals(Float.NEGATIVE_INFINITY)) {
            writer.write("'-INF'");
        } else if (flt.equals(Float.NaN)) {
            writer.write("fn:number(())"); // poor man's way to write NaN
        } else {
            writer.write(o.toString());
        }
        writer.write(")");
    } else if (o instanceof Double) {
        Double dbl = (Double) o;
        writer.write("xs:double(");
        if (dbl.equals(Double.POSITIVE_INFINITY)) {
            writer.write("'INF'");
        } else if (dbl.equals(Double.NEGATIVE_INFINITY)) {
            writer.write("'-INF'");
        } else if (dbl.equals(Double.NaN)) {
            writer.write("fn:number(())"); // poor man's way to write NaN
        } else {
            writer.write(o.toString());
        }
        writer.write(")");
    } else if (o instanceof Boolean) {
        writer.write("xs:boolean('");
        writer.write(o.toString());
        writer.write("')");
    } else if (o instanceof BigDecimal) {
        writer.write("xs:decimal(");
        writer.write(o.toString());
        writer.write(")");
    } else if (o instanceof Date) {
        // We want something like: 2006-04-30T01:28:30.499-07:00
        // We format to get:       2006-04-30T01:28:30.499-0700
        // Then we add in the colon
        writer.write("xs:dateTime('");
        String d = dateFormat.format((Date) o);
        writer.write(d.substring(0, d.length() - 2));
        writer.write(":");
        writer.write(d.substring(d.length() - 2));
        writer.write("')");
    } else if (o instanceof XMLGregorianCalendar) {
        XMLGregorianCalendar greg = (XMLGregorianCalendar) o;
        QName type = greg.getXMLSchemaType();
        if (type.equals(DatatypeConstants.DATETIME)) {
            writer.write("xs:dateTime('");
        } else if (type.equals(DatatypeConstants.DATE)) {
            writer.write("xs:date('");
        } else if (type.equals(DatatypeConstants.TIME)) {
            writer.write("xs:time('");
        } else if (type.equals(DatatypeConstants.GYEARMONTH)) {
            writer.write("xs:gYearMonth('");
        } else if (type.equals(DatatypeConstants.GMONTHDAY)) {
            writer.write("xs:gMonthDay('");
        } else if (type.equals(DatatypeConstants.GYEAR)) {
            writer.write("xs:gYear('");
        } else if (type.equals(DatatypeConstants.GMONTH)) {
            writer.write("xs:gMonth('");
        } else if (type.equals(DatatypeConstants.GDAY)) {
            writer.write("xs:gDay('");
        }
        writer.write(greg.toXMLFormat());
        writer.write("')");
    } else if (o instanceof Duration) {
        Duration dur = (Duration) o;
        /*
        // The following fails on Xerces
        QName type = dur.getXMLSchemaType();
        if (type.equals(DatatypeConstants.DURATION)) {
          writer.write("xs:duration('");
        }
        else if (type.equals(DatatypeConstants.DURATION_DAYTIME)) {
          writer.write("xdt:dayTimeDuration('");
        }
        else if (type.equals(DatatypeConstants.DURATION_YEARMONTH)) {
          writer.write("xdt:yearMonthDuration('");
        }
        */
        // If no years or months, must be DURATION_DAYTIME
        if (dur.getYears() == 0 && dur.getMonths() == 0) {
            writer.write("xdt:dayTimeDuration('");
        }
        // If has years or months but nothing else, must be DURATION_YEARMONTH
        else if (dur.getDays() == 0 && dur.getHours() == 0 && dur.getMinutes() == 0 && dur.getSeconds() == 0) {
            writer.write("xdt:yearMonthDuration('");
        } else {
            writer.write("xs:duration('");
        }
        writer.write(dur.toString());
        writer.write("')");
    }

    else if (o instanceof org.jdom.Element) {
        org.jdom.Element elt = (org.jdom.Element) o;
        writer.write("xdmp:unquote('");
        // Because "&lt;" in XQuery is the same as "<" I need to double escape any ampersands
        writer.write(new org.jdom.output.XMLOutputter().outputString(elt).replaceAll("&", "&amp;")
                .replaceAll("'", "''"));
        writer.write("')/*"); // make sure to return the root elt
    } else if (o instanceof org.jdom.Document) {
        org.jdom.Document doc = (org.jdom.Document) o;
        writer.write("xdmp:unquote('");
        writer.write(new org.jdom.output.XMLOutputter().outputString(doc).replaceAll("&", "&amp;")
                .replaceAll("'", "''"));
        writer.write("')");
    } else if (o instanceof org.jdom.Text) {
        org.jdom.Text text = (org.jdom.Text) o;
        writer.write("text {'");
        writer.write(escapeSingleQuotes(text.getText()));
        writer.write("'}");
    } else if (o instanceof org.jdom.Attribute) {
        // <fake xmlns:pref="http://uri.com" pref:attrname="attrvalue"/>/@*:attrname
        // <fake xmlns="http://uri.com" attrname="attrvalue"/>/@*:attrname
        org.jdom.Attribute attr = (org.jdom.Attribute) o;
        writer.write("<fake xmlns");
        if ("".equals(attr.getNamespacePrefix())) {
            writer.write("=\"");
        } else {
            writer.write(":" + attr.getNamespacePrefix() + "=\"");
        }
        writer.write(attr.getNamespaceURI());
        writer.write("\" ");
        writer.write(attr.getQualifiedName());
        writer.write("=\"");
        writer.write(escapeSingleQuotes(attr.getValue()));
        writer.write("\"/>/@*:");
        writer.write(attr.getName());
    } else if (o instanceof org.jdom.Comment) {
        org.jdom.Comment com = (org.jdom.Comment) o;
        writer.write("comment {'");
        writer.write(escapeSingleQuotes(com.getText()));
        writer.write("'}");
    } else if (o instanceof org.jdom.ProcessingInstruction) {
        org.jdom.ProcessingInstruction pi = (org.jdom.ProcessingInstruction) o;
        writer.write("processing-instruction ");
        writer.write(pi.getTarget());
        writer.write(" {'");
        writer.write(escapeSingleQuotes(pi.getData()));
        writer.write("'}");
    }

    else if (o instanceof QName) {
        QName q = (QName) o;
        writer.write("fn:expanded-QName('");
        writer.write(escapeSingleQuotes(q.getNamespaceURI()));
        writer.write("','");
        writer.write(q.getLocalPart());
        writer.write("')");
    }

    else {
        writer.write("error('XQuery tried to retrieve unsupported type: " + o.getClass().getName() + "')");
    }

    writer.flush();
}

From source file:eu.supersede.gr.utility.PointsLogic.java

/**
 * Sort a map by values (in this case the number of moves).
 * @param gamePlayerVotes/*from  w  ww . j  a v  a 2 s .  co m*/
 * @return
 */
private LinkedHashMap<User, Float> sortHashMapByValues(Map<User, Float> gamePlayerVotes) {
    List<User> mapKeys = new ArrayList<>(gamePlayerVotes.keySet());
    List<Float> mapValues = new ArrayList<>(gamePlayerVotes.values());
    Collections.sort(mapValues);
    Collections.sort(mapKeys, new UserComparator());

    LinkedHashMap<User, Float> sortedMap = new LinkedHashMap<>();

    Iterator<Float> valueIt = mapValues.iterator();

    while (valueIt.hasNext()) {
        Float val = valueIt.next();
        Iterator<User> keyIt = mapKeys.iterator();

        while (keyIt.hasNext()) {
            User key = keyIt.next();
            Float comp1 = gamePlayerVotes.get(key);
            Float comp2 = val;

            if (comp1.equals(comp2)) {
                keyIt.remove();
                sortedMap.put(key, val);
                break;
            }
        }
    }

    return sortedMap;
}

From source file:net.ontopia.topicmaps.query.impl.basic.QueryMatches.java

/**
 * INTERNAL: Returns the index of the given float constant in the table.
 *///from  w  ww  .jav  a2s .  c om
public int getIndex(Float num) {
    for (int ix = 0; ix < colcount; ix++)
        if (num.equals(columnDefinitions[ix]))
            return ix;
    return -1;
}

From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java

private void loadDataTableData(List inStr, boolean resetIndexYear) {
    selectBeginYears = new ArrayList();
    selectEndYears = new ArrayList();
    selectIndexDate = new ArrayList();
    selectEndYears.add(new SelectItem(3000, "Max"));
    lowValStandard = new Float(0);
    lowValIndex = new Float(100);
    highValStandard = new Float(0);
    highValIndex = new Float(0);
    boolean indexesAvailable = false;

    int startYearTransform = 0;
    boolean startYearTransformSet = false;
    int endYearTransform = 3000;
    boolean endYearTransformSet = false;
    boolean firstYearSet = false;
    String maxYear = "";
    String output = "";
    String indexedOutput = "";
    String csvOutput = csvColumnString + "\n";

    boolean addIndexDate = false;
    boolean[] getIndexes = new boolean[vizLines.size() + 1];
    boolean firstIndexDateSet = false;
    int firstIndexDate = 0;
    int indexYearForCalc = 0;
    //Start year entered by user
    if (new Integer(startYear.toString()).intValue() != 0) {
        startYearTransform = new Integer(startYear.toString()).intValue();
        startYearTransformSet = true;//from  ww  w .  ja va2s . c  o m
    }
    //End year entered by user
    if (new Integer(endYear.toString()).intValue() != 3000) {
        endYearTransform = new Integer(endYear.toString()).intValue();
        endYearTransformSet = true;
    }
    //Index year entered by user
    if (indexDate != null && !indexDate.isEmpty()) {
        indexYearForCalc = new Integer(indexDate.toString()).intValue();
    }
    //reset arrays for indexes and start/end dates
    for (int i = 1; i < vizLines.size() + 1; i++) {
        getIndexes[i] = false;
    }

    String[] indexVals = new String[vizLines.size() + 1];
    //First determine the number of data points we're dealing with
    int maxLength = 0;
    for (Object inObj : inStr) {
        String nextStr = (String) inObj;
        String[] columnDetail = nextStr.split("\t");
        String[] test = columnDetail;
        if (test.length - 1 > maxLength) {
            maxLength = test.length - 1;
        }
    }

    //Then get start and end dates and index dates...
    for (Object inObj : inStr) {
        String nextStr = (String) inObj;
        String[] columnDetail = nextStr.split("\t");
        String[] test = columnDetail;
        if (!startYearTransformSet && test.length > 1) {
            startYearTransformSet = true;
            startYearTransform = new Integer(test[0]).intValue();
        }
        if (!endYearTransformSet && test.length > 1
                && (new Integer(test[0]).intValue() > endYearTransform || endYearTransform == 3000)) {
            endYearTransform = new Integer(test[0]).intValue();
        }

        addIndexDate = true;
        for (int i = 0; i < test.length; i++) {
            if (test.length - 1 == maxLength) {
                if (i > 0 && (test[i].isEmpty() || new Float(test[i]).floatValue() == 0)) {
                    addIndexDate = false;
                }
            } else {
                addIndexDate = false;
            }
        }
        //found earliest date where all streams have data
        if (addIndexDate) {
            for (int k = 1; k < maxLength + 1; k++) {
                getIndexes[k] = true;
            }
            if (!firstIndexDateSet) {
                firstIndexDateSet = true;
                firstIndexDate = new Integer(test[0].toString()).intValue();
            }
            selectIndexDate.add(new SelectItem(test[0], test[0]));
        }
        if (!resetIndexYear) {
            indexYearForCalc = Math.max(firstIndexDate, indexYearForCalc);
        } else {
            if (new Integer(this.startYear).intValue() > 0) {
                indexYearForCalc = Math.max(firstIndexDate, new Integer(this.startYear).intValue());
            } else {
                indexYearForCalc = firstIndexDate;
            }
        }
        indexDate = new Integer(indexYearForCalc).toString();
    }

    transformedData = new String[maxLength + 1];
    transformedDataIndexed = new String[maxLength + 1];

    boolean indexesDone = false;
    // scroll through table data to load transformed data
    for (Object inObj : inStr) {
        String nextStr = (String) inObj;
        String[] columnDetail = nextStr.split("\t");
        String[] test = columnDetail;
        String col = "";
        String csvCol = "";
        int testYear = 0;
        if (test.length > 1) {
            for (int i = 0; i < test.length; i++) {
                if (i == 0) {
                    testYear = new Integer(test[0]).intValue();
                    col = test[i];
                    csvCol = test[i];

                    if (!firstYearSet) {
                        selectBeginYears.add(new SelectItem(col, "Min"));
                        firstYearSet = true;
                    }

                    maxYear = col;
                    selectBeginYears.add(new SelectItem(col, col));
                    selectEndYears.add(new SelectItem(col, col));
                    transformedData[i] = "";
                } else {
                    col = col + ", " + test[i];
                    csvCol = csvCol + ", " + test[i];
                    if (testYear >= startYearTransform && testYear <= endYearTransform) {
                        transformedData[i] += test[0] + ", " + test[i] + ", ";
                    }
                    if (!test[i].isEmpty() && testYear >= startYearTransform && testYear <= endYearTransform) {
                        if (lowValStandard.equals(new Float(0))
                                || lowValStandard.compareTo(new Float(test[i])) > 0) {
                            lowValStandard = new Float(test[i]);
                        }
                        if (highValStandard.equals(new Float(0))
                                || highValStandard.compareTo(new Float(test[i])) < 0) {
                            highValStandard = new Float(test[i]);
                        }
                    }

                    Double testIndexVal = new Double(0);
                    if (!test[i].isEmpty()) {
                        testIndexVal = new Double(test[i]);
                    }
                    if (getIndexes[i] && testIndexVal > 0) {
                        indexVals[i] = test[i];
                        getIndexes[i] = false;
                    }
                    boolean allfalse = true;
                    for (int j = 1; j < vizLines.size() + 1; j++) {
                        if (getIndexes[j] == true) {
                            allfalse = false;
                        }
                    }

                    if (allfalse && !indexesDone && testYear == indexYearForCalc) {
                        for (int q = 1; q < test.length; q++) {
                            indexVals[q] = test[q];
                            indexesDone = true;
                            indexesAvailable = true;
                        }
                    }
                }

            }
            col = col + ";";
            csvCol = csvCol + "\n";
        } else {
        }
        output = output + col;
        csvOutput = csvOutput + csvCol;
    }
    for (Object inObj : inStr) {
        String nextStr = (String) inObj;
        String[] columnDetail = nextStr.split("\t");
        String[] test = columnDetail;
        String indexCol = "";
        int testYear = 0;
        if (test.length > 1) {
            for (int i = 0; i < test.length; i++) {
                if (i == 0) {
                    indexCol = test[i];
                    testYear = new Integer(test[0]).intValue();
                } else {

                    Float numerator = new Float(0);
                    if (!test[i].isEmpty()) {
                        numerator = new Float(test[i]);
                    }
                    Float denominator = new Float(0);
                    if (indexesAvailable && indexVals[i] != null && !indexVals[i].isEmpty()) {
                        denominator = new Float(indexVals[i]);
                    }

                    Float result = null;
                    Object outputIndex = null;
                    if (!denominator.equals(new Float(0)) && !numerator.equals(new Float(0))) {
                        outputIndex = Math.round((numerator / denominator) * new Double(10000))
                                / new Float(100);
                        result = (numerator / denominator) * new Float(100);
                        if ((lowValIndex.compareTo(result) > 0)) {
                            if (testYear >= startYearTransform && testYear <= endYearTransform) {
                                lowValIndex = result;
                            }
                        }
                        if (!test[i].isEmpty()
                                && (highValIndex.equals(new Float(0)) || highValIndex.compareTo(result) < 0)) {
                            if (testYear >= startYearTransform && testYear <= endYearTransform) {
                                highValIndex = result;
                            }
                        }
                    } else {
                        outputIndex = "";
                    }
                    if (testYear >= startYearTransform && testYear <= endYearTransform) {
                        transformedDataIndexed[i] += test[0] + ", " + outputIndex.toString() + ", ";
                    }
                    indexCol = indexCol + ", " + outputIndex.toString();
                }
            }
            indexCol = indexCol + ";";
        }
        indexedOutput = indexedOutput + indexCol;
    }
    SelectItem setSI = selectEndYears.get(0);
    setSI.setValue(maxYear);
    selectEndYears.set(0, setSI);
    csvString = csvOutput;
    dataString = output;
    indexedDataString = indexedOutput;
    cleanUpTransformedData(startYearTransform, endYearTransform);
}

From source file:org.etudes.component.app.jforum.dao.generic.GradeDaoGeneric.java

/**
 * compare the scores, comments, released of evaluation objects
 * //from w w w  .ja  va2 s .  c  om
 * @param exisEval   The existing evaluation
 * 
 * @param modEval   The modified evaluation
 * 
 * @return      True - if scores or comments changed
 *             False - if scores and comments are not changed
 */
protected boolean checkEvaluationChanges(Evaluation exisEval, Evaluation modEval) {
    if ((exisEval == null) && (modEval == null)) {
        return false;
    }

    if (((exisEval == null) && (modEval != null)) || ((exisEval != null) && (modEval == null))) {
        return true;
    } else {
        // check for score changes
        Float exisScore = exisEval.getScore();
        Float modScore = modEval.getScore();

        if ((exisScore == null) && (modScore == null)) {
            // continue to check comments
        } else if (((exisScore == null) && (modScore != null)) || ((exisScore != null) && (modScore == null))) {
            return true;
        } else if (!exisScore.equals(modScore)) {
            return true;
        }

        // check for comments changes
        String exisComments = exisEval.getComments();
        String modComments = modEval.getComments();

        if ((exisComments == null) && (modComments == null)) {
        } else if (((exisComments == null) && (modComments != null))
                || ((exisComments != null) && (modComments == null))) {
            return true;
        } else if (!exisComments.equalsIgnoreCase(modComments)) {
            return true;
        }

        // check for released
        boolean exisReleased = exisEval.isReleased();
        boolean modReleased = modEval.isReleased();

        if (exisReleased != modReleased) {
            return true;
        }
    }

    return false;
}

From source file:org.etudes.mneme.tool.QuestionScoreDelegate.java

/**
 * {@inheritDoc}/*w w  w .j  a  v  a  2  s. c om*/
 */
public String format(Context context, Object value) {
    if (value == null)
        return null;
    if (!(value instanceof Question))
        return value.toString();
    Question question = (Question) value;

    Submission submission = null;
    Object o = context.get("submission");
    if ((o != null) && (o instanceof Submission)) {
        submission = (Submission) o;
    }

    Assessment assessment = null;
    if (submission != null) {
        assessment = submission.getAssessment();
    } else {
        o = context.get("assessment");
        if (o instanceof Assessment) {
            assessment = (Assessment) o;
        }
    }
    if (assessment == null)
        return value.toString();

    // use the {}/{} format if doing feedback, or just {} if not.
    StringBuffer rv = new StringBuffer();

    Boolean review = (Boolean) context.get("review");
    if (review == null)
        review = Boolean.FALSE;
    Boolean grading = (Boolean) context.get("grading");
    if (grading == null)
        grading = Boolean.FALSE;
    Boolean viewWork = (Boolean) context.get("viewWork");
    if (viewWork == null)
        viewWork = Boolean.FALSE;

    String selector = "worth-points";
    boolean partialCorrect = false;

    // if we are doing review just now, and if we are needing review and it's set, and if the submission has been graded
    if ((review || grading) && (submission != null) && (submission.getIsReleased() || grading || viewWork)) {
        // find the answer
        Answer answer = null;
        for (Answer a : submission.getAnswers()) {
            if (a.getQuestion().equals(question)) {
                answer = a;
                break;
            }
        }

        if (answer != null) {
            boolean showCorrect = answer.getShowCorrectReview();
            boolean showPartialCorrect = answer.getShowPartialCorrectReview();

            // if we are doing question score feedback
            if (showCorrect || showPartialCorrect || grading || viewWork) {
                // the auto-scores for this answered question
                Float score = null;

                if (grading) {
                    score = answer.getAutoScore();
                } else {
                    score = answer.getTotalScore();
                }

                // evaluation non-submit submissions always show a 0, not null (ungraded) score
                // submissions marked as evaluated, always show a 0, not null (ungraded) score
                if (score == null) {
                    if ((submission.getCompletionStatus() == SubmissionCompletionStatus.evaluationNonSubmit)
                            || (submission.getEvaluation().getEvaluated())) {
                        score = 0.0f;
                    }
                }

                rv.append(context.getMessages().getString("score") + ":&nbsp;" + formatScore(context, score)
                        + "&nbsp;&nbsp;&nbsp;");

                selector = "of-points";
            }
            if (showPartialCorrect && !showCorrect && !answer.getQuestion().getType().equals("mneme:TrueFalse"))
                partialCorrect = true;
        }
    }

    // add the possible points for the question
    Float score = question.getPoints();
    if (score.equals(Float.valueOf(1))) {
        selector += "-singular";
    }
    Object[] args = new Object[1];
    args[0] = formatScore(context, score);
    rv.append(context.getMessages().getFormattedMessage(selector, args));

    if (partialCorrect)
        rv.append(context.getMessages().getFormattedMessage("partial-correct", args));

    return rv.toString();
}

From source file:org.etudes.mneme.tool.SubmissionScoreDelegate.java

/**
 * {@inheritDoc}/*from   w  w  w.  java2 s .  c om*/
 */
public String format(Context context, Object value) {
    // submission or assessment
    if (value == null)
        return null;
    Submission submission = null;
    Assessment assessment = null;

    if (value instanceof Submission) {
        submission = (Submission) value;
        assessment = submission.getAssessment();
    }

    else if (value instanceof Assessment) {
        assessment = (Assessment) value;
    }

    if (assessment == null)
        return value.toString();

    // use the {}/{} format if doing feedback, or just {} if not.
    StringBuffer rv = new StringBuffer();

    Boolean review = (Boolean) context.get("review");

    String selector = "worth-points";

    // if we are doing review and the submission has been graded
    if ((review != null) && review && (submission != null) && submission.getIsReleased()) {
        // the total score
        rv.append("<img style=\"border-style: none;\" src=\"" + context.get("sakai.return.url")
                + "/icons/grade.png\" alt=\"" + context.getMessages().getString("grade") + "\" />");
        Float score = submission.getTotalScore();
        rv.append(context.getMessages().getString("grade") + ":&nbsp;" + FormatScoreDelegate.formatScore(score)
                + "&nbsp;&nbsp;&nbsp;");

        selector = "of-points";

        boolean partial = submission.getHasUnscoredAnswers();
        if (partial) {
            selector += "-partial";
        }
        if (assessment.getMinScoreSet().booleanValue() && (assessment.getType() != AssessmentType.survey)) {
            float minScore = (assessment.getMinScore() * assessment.getParts().getTotalPoints().floatValue())
                    / 100;
            if (score.floatValue() >= minScore) {
                context.put("minscoremet", Boolean.TRUE);
            }
        }

    }

    // add the total possible points for the assessment
    Float score = assessment.getParts().getTotalPoints();
    if (score.equals(Float.valueOf(1))) {
        selector += "-singular";
    }
    Object[] args = new Object[1];
    args[0] = FormatScoreDelegate.formatScore(score);
    rv.append(context.getMessages().getFormattedMessage(selector, args));

    return rv.toString();
}

From source file:org.gbif.portal.dto.util.BoundingBoxDTO.java

public boolean nullSafeEquals(Float original, Float comparedTo) {
    if (original == null && comparedTo == null)
        return true;
    if (original != null && comparedTo == null)
        return false;
    if (original == null && comparedTo != null)
        return false;
    return original.equals(comparedTo);
}