Recent

Author Topic: Single/Float Format  (Read 5270 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2255
    • Lazarus and Free Pascal italian community
Single/Float Format
« on: July 09, 2010, 12:53:53 pm »
What if a single variable have a value type 12.43168
and I want a string that displays 12.43? Somebody can help me? Example?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

Leledumbo

  • Hero Member
  • *****
  • Posts: 8740
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Single/Float Format
« Reply #1 on: July 09, 2010, 01:54:17 pm »
Code: [Select]
uses
  SysUtils;

var
  s: String;
begin
  s := FloatToStrF(12.43168,ffFixed,2,2); // I guess the 3rd param could be ignored

 

TinyPortal © 2005-2018