PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, August 7, 2022

[FIXED] How to keep 2 decimal places in delphi?

 August 07, 2022     decimal, delphi     No comments   

Issue

I have to selected some column data from a database table and make this data with two decimal places only. I see this

SQL.Strings = ('select' #9'my_index '#9'his_index,'...

What is that #9?
How can I deal with the data I selected to make it only keep two decimal places?
I am very new to Delphi.
Thanks!


Solution

#9 is the character with code 9, TAB.

If you want to convert a floating point value to a string with 2 decimal places you use one of the formatting functions, e.g. Format():

var
  d: Double;
  s: string;
...
d := Sqrt(2.0);
s := Format('%.2f', [d]);


Answered By - David Heffernan
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing