Was the pointer casted from the original type?
For example
1 2
float a=40;
char *p=(char *)&a;
If that's the case, then it's impossible because the cast destroyed all type information.
If the pointer points to a decimal representation of the number, such as "40.5", then you can find out the type by checking if it has decimals. If it doesn't then it's an int. Otherwise it's a float.