TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Dart

    Dart Number Methods

    Overview

    In Dart, there are multiple number methods that come built-in and are useful when dealing with numbers. In this tutorial, we will examine some of the most frequently used methods.

    Dart Number Methods

    The commonly used number methods in Dart programming language are as follows:

     

     

    Number Method Method Description
    abs() The abs() method returns the absolute value of the given number.
    ceil() The ceil() method returns the ceiling value of the given number. It returns the smallest integer greater than or equal to the given number.
    floor() The floor() method returns the floor value of the given number. It returns the largest integer less than or equal to the given number.
    round() The round() method returns the round of the number. This method returns the nearest integer. The round() method rounds to the nearest even number in case of a tie.
    For example, 5.5 would be rounded to 6.
    compareTo() This compareTo() method compares the value with another number
    remainder() The remainder() method returns the truncated remainder after dividing the two numbers.
    toDouble() The toDouble() method returns the double equivalent representation of the given number.
    toInt() The toInt() method returns the integer equivalent representation of the given number. This method converts a double to an integer by discarding the fractional part of the
    double number.
    toString() The toString() method returns the String equivalent representation of the given number.
    truncate() The truncate() method returns the integer after discarding the fraction digits.
    parse() The parse() method converts and returns the numeric value of the String.

    Example

    abs()

    The abs() method returns the absolute value of the given number.

    Sample Dart program to show the usage of the abs() method.

    /*
    Dart Number Methods demo Program
    Dart Tutorials – www.TestingDocs.com
    */

    void main()
    {
        // declare a negative number
        int negative_number = -7;
        int abs_number = negative_number.abs();
        print(abs_number);
    }

     

    Dart Number Methods

    We can use these methods to perform various mathematical operations and
    conversions in the Dart programs.

    —

    Dart Tutorials

    Dart tutorial on this website can be found at:

    https://www.testingdocs.com/dart-tutorials-for-beginners/

    More information on Dart:

    https://dart.dev/

    Related Posts

    Dart Compilation Techniques

    Dart /

    Dart Compilation Techniques

    Dart String Interpolation

    Dart /

    Dart String Interpolation

    Dart Lists

    Dart /

    Dart Lists

    Dart /

    Dart String Methods

    Dart Print Expression

    Dart /

    Dart print() function

    ‹ Dart parse() function› Dart print() function

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com