loading...

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

ishwar profile image ishwar chandra tiwari ・1 min read
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

pic
Editor guide
 

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.