Double as Fraction String

Please discuss general Delphi programming topics here.

Double as Fraction String

Postby w2m » March 9th, 2004, 11:06 pm

Dumb question I guess...

If I have a variable ShutterSpeed: double that is 0.02 or 1/200 how can I display ShutterSpeed as 1/200 as a string?
0.05 = 1/50sec
0.01 = 1/100sec
0.02 = 1/200sec
0.50 = 1/2sec


I googled for a while but could not find anything that works.

Regards
Bill
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA

Postby Kambiz » March 17th, 2004, 9:20 am

Code: Select all
ShutterSpeedLabel.Caption := Format('1/%d sec', [Round(1 / ShutterSpeed)]);


Hope that it helps.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Thanks...

Postby w2m » March 20th, 2004, 3:19 pm

Thanks... that did the trick... the method I was using was too complicated and used the lowest common denometer so it did not work with typical shutter speeds.

Bill
w2m
w2m
Senior Member
Senior Member
 
Posts: 76
Joined: March 8th, 2003, 7:11 pm
Location: New York, USA


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron