The java.lang.Float.compare() method compares the two specified float values. The sign of the integer value returned is the same as that of the integer that would be returned by the call − Show
new Float(f1).compareTo(new Float(f2)) DeclarationFollowing is the declaration for java.lang.Float.compare() method public static int compare(float f1, float f2)Parameters
Return ValueThis method returns the value 0 if f1 is numerically equal to f2; a value less than 0 if f1 is numerically less than f2; and a value greater than 0 if f1 is numerically greater than f2. ExceptionNA ExampleThe following example shows the usage of java.lang.Float.compare() method. package com.tutorialspoint; import java.lang.*; public class FloatDemo { public static void main(String[] args) { // compares the two specified float values float f1 = 22.30f; float f2 = 88.67f; int retval = Float.compare(f1, f2); if(retval > 0) { System.out.println("f1 is greater than f2"); } else if(retval < 0) { System.out.println("f1 is less than f2"); } else { System.out.println("f1 is equal to f2"); } } }Let us compile and run the above program, this will produce the following result − f1 is less than f2java_lang_float.htm
In this tutorial, you'll learn to use expressions and conditions to compare multiple values in Advanced mode. When you create a cloud flow, you can use the Condition card in basic mode to quickly compare a single value with another value. However, there're times when you need to compare multiple values. For example, you might want to check the value of a few columns in a spreadsheet or database table. You can use any combination of the following logical expressions in your conditions.
PrerequisitesHere's what you'll need to complete this walkthrough.
Use the 'or' expressionSometimes your workflow needs to take an action if the value of an item is valueA or valueB. For example, you may be tracking the status of tasks in a spreadsheet table. Assume that the table has a column named Status and the possible values in this column are:
Here's an example of what the spreadsheet might look like:
Given the preceding spreadsheet, you want to use Power Automate to remove all rows with a Status column that's set to completed or unnecessary. Let's create the flow. Start with a blank flow
Add a trigger to your flow
Select the spreadsheet and get all rows
Check the status column of each row
Delete matching rows from the spreadsheet
Run the flow with the 'or' expressionThe flow runs after you save it. If you created the spreadsheet shown earlier in this tutorial, here's what it looks like after the run completes.
Notice all data from rows that had completed or unnecessary in the Status column were deleted. Use the 'and' expressionAssume you have a spreadsheet table with two columns. The column names are Status and Assigned. Assume also that you want to delete all rows if the Status column's value is blocked and the Assigned column's value is John Wonder. To accomplish this task, follow all steps earlier in this tutorial, but when you edit the Condition card in advanced mode, use the and expression shown here. @and(equals(item()?['Status'], 'blocked'), equals(item()?['Assigned'], 'John Wonder')) Here's an example of a Condition card.
Run the flow with the 'and' expressionIf you've followed the steps in this tutorial, your spreadsheet should look similar to the following screenshot.
After your flow runs, your spreadsheet should look similar to the following screenshot.
Use the 'empty' expressionNotice that there are several empty rows in the spreadsheet now. To remove them, use the empty expression to identify all rows that don't have text in the Assigned and Status columns. To accomplish this task, follow all steps listed in the Use the 'and' expression section earlier in this tutorial. When you edit the Condition card in advanced mode, use the following empty expression. @and(empty(item()?['Status']), empty(item()?['Assigned'])) Your Condition card should look similar to the following screenshot.
After your flow runs, the spreadsheet should look similar to the following screenshot.
Notice extra lines are removed from the table. Use the 'greater' expressionImagine you've bought baseball tickets for your coworkers and you're using a spreadsheet to ensure you're reimbursed by each person. You can quickly create a cloud flow that sends a daily email to each person who hasn't paid the full amount. Use the greater expression to identify the employees who haven't paid the full amount. You can then automatically send a reminder email to those who haven't paid in full. Here's a view of the spreadsheet.
Here's the implementation of the greater expression that identifies all persons who have paid less than the amount due from them. @greater(item()?['Due'], item()?['Paid']) Use the 'less' expressionImagine you've bought baseball tickets for your coworkers, and you're using a spreadsheet to ensure you're reimbursed by each person by the date to which everyone agreed. You can create a cloud flow that sends a reminder email to each person who hasn't paid the full amount if the current date is less than one day before the due date. Use the and expression with the less expression since there are two conditions being validated.
Combine the 'greater' and 'less' expressions in an 'and' expressionUse the greater expression to identify the employees who have paid less than the full amount due and use the less expression to determine if the payment due date is less than one day away from the current date. You can then use the Send an email action to send reminder emails to those employees who haven't paid in full and the due date is less than one day away. Here's a view of the spreadsheet table.
Here's the implementation of the and expression that identifies all employees who have paid less than the amount due from them and the due date is less than one day away from the current date. @and(greater(item()?['Due'], item()?['Paid']), less(item()?['dueDate'], addDays(utcNow(),1))) Use functions in expressionsSome expressions get their values from runtime actions that might not yet exist when a cloud flow starts to run. To reference or work with these values in expressions, you can use functions that the Workflow Definition Language provides. More information. To learn more, go to Reference guide to workflow expression functions in Azure Logic Apps and Power Automate. |