Mickey Shine
Mickey Shine

Reputation: 12549

How to make CGFloat using double type in CGRect?

I am doing iPhone development and how to make CGRect return double value? I found there was a macro "#define CGFLOAT_IS_DOUBLE", but how can I change it?

Upvotes: 2

Views: 3699

Answers (2)

sbooth
sbooth

Reputation: 16976

You can't change CGFLOAT_IS_DOUBLE- it is defined in CGBase.h and lets you know the width of CGFloat. In 32-bit apps it will be float, and in 64-bit apps it will be double.

Do you actually need double precision or could you just use CGFloat everywhere?

If you do need doubles you'll have to cast, as CVertex says.

Upvotes: 3

CVertex
CVertex

Reputation: 18237

Wrap the CGRect or create helper methods that just do casting?

double d= (double)rect.size.height;

floats perform better on the iphone (I think)

Upvotes: 2

Related Questions