question

TZacks-2728 avatar image
0 Votes"
TZacks-2728 asked Paul-5034 commented

C# How to convert Point to Inches

I am looking for a function where i will send point and function return inches in values. please share sample code. thanks

dotnet-csharp
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What is a point in your application? A point found on a graph? A point on a map. font point? A point in an image?

Assuming this is a font question, 72 points is one inch. Mathematically the conversion factor is (1in /72 pt). To solve for inches just multiple point by 1/72 or 0.01388.

1 Vote 1 ·

1 Answer

Paul-5034 avatar image
1 Vote"
Paul-5034 answered Paul-5034 commented
 float PointsToInches(float points) {
     return points / 72F;
 }

Usage:

 var inches = PointsToInches(10);

To convert 10 points to inches.


· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

what is 72F ? f means here float ?

if i do not use 72F rather use points / 72; then i will get wrong output ?

thanks

0 Votes 0 ·

Correct - 'f' denotes that it's a floating point number rather than an integer. When you perform an arithmetic operation in C#, if the number on either side of the expression is a float then the result is a float. You could use '72' instead of '72F' in this case because 'points' is a float, but I just wanted to make it clear that this is a floating point operation.

1 Vote 1 ·