DEV Community

ishwar
ishwar

Posted on

3 2

Delete digits after two decimal point without rounding its value in flutter?

var num1 = 10.12345678

What should i do with num1 to delete digits after two decimal point without rounding its value.
I need output as 10.12

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
      title: ' Delete digits after two decimal point ',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: MyHome(),
    ));

class MyHome extends

Top comments (1)

Collapse
 
brogrammerben profile image
Ben • Edited

Hack solution would be to multiply by 100, take the integer value, divide by 100.

Formal solution would be to just format the number to 2 decimal points. That should truncate.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more