last day (14 days later) » 

6:41 PM
0
Q: Get value from FourCC data types in Swift

Sascha SimonI have some FourCC data types that I want to convert to a double value, but unfortunately I am stuck and don't know how. SP78 SP3C SP69 SP4B SP5A Is there some sort of framework that supports those types? I have the [UInt8] array containing the bytes and the description.

 
What exactly are you trying to do? FourCCs are used to identify file formats. Why would you want to convert them to a double? What would a double output even mean?
 
When reading data from hardware sensors on macOS, the data is returned as a FourCC. Now I have to convert the bits to a double.
 
Do the bits of the FourCC encode a valid double already?
 
No, that's the "problem" ;)
 
So what information does the FourCC encode, exactly? You can't convert it to double if you don't know what the bits represent. This question is incomplete, and as is, makes no sense at all. The question is currently essentially "I have some FourCC data that stores some value of some kind, I guess, can you guys come up with some sense of it and somehow convert it to double?"
 
6:41 PM
Well, the bit representation is in the actual name of the FourCC, isn't it? So I only have SP.. types, that means that it is a signed float. The last two digits represent the integer and fraction bits, so for SP78 that would be 7 integer bit and 8 fraction bits. I have to admit that bit-shifting is not my strength...
Hi
 
Hey
"the bit representation is in the actual name of the FourCC, isn't it?"
A FourCC is just 32 bits
that's it
any sort of meaning that you derive out of those bits is entirely done by you
you didn't mention this anywhere
"So I only have SP.. types, that means that it is a signed float. The last two digits represent the integer and fraction bits, so for SP78 that would be 7 integer bit and 8 fraction bits." you should have mentioned this too
Where are you getting this data from? What sensors? What functions? Are they documented?
Hey @MartinR
 
sorry
 
Hi.
 
I thought that FourCC are a special macOS type
and then it would be clear what those mean
 
@SaschaSimon Nope, FourCC just means "four character codes"
it literally just means "four characters"
any higher level meaning you derive out of those 4 characters is by convention
OSType is one example of a FourCC convention
 
6:47 PM
FourCC is a four-character literal, representing an 32-bit integer.
 
A FourCC is a Int32. "SP67" is represented as a UInt with decimal value 892478758. This particular FourCC isn't a valid OSType, for example
 
8
A: fpe2 and sp78 data types?

Chris J. KiickWhile there doesn't seem to be any "official" documentation of these type names, they are generic enough to figure out. FP = Floating point, unsigned. SP = floating point, signed. The last two (hex) digits indicate the integer/fraction bits. The total tells us that the value fits into 16 bits...

This guy explains how the data types are "formatted"
 
Okay, so give use a piece of sample input to work with
Now that I know by what convention you're interpreting these FourCC values, I can help you now
 
would be great ;)
 

last day (14 days later) »