DEV Community

ishwar chandra tiwari
ishwar chandra tiwari

Posted on

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

Discussion (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.