Gamestudio Links
Zorro Links
Newest Posts
Help with Data import to T1
by AndrewAMD
45 minutes 48 seconds ago
Using ":L" & ":S" causes 2 possible bug(s) or is it bad coding?
by AndrewAMD
Today at 03:54
Correlation -1.#IND00
by AndrewAMD
01/21/19 17:37
Basic thread safety question
by Superku
01/20/19 18:15
Blog Post: Get Historical Data from Darwinex REST API w/ Zorro
by AndrewAMD
01/19/19 22:19
Reseting a static variable - the next day
by OptimusPrime
01/19/19 19:48
Train algorithms separatery
by 3dgamelight
01/18/19 10:37
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
12 registered (Iglarion, AndrewAMD, Michael_Schwarz, ags, chsmac85, kvm, ibne, alibaba, 3 invisible), 431 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
laz, ramonne, SibJac, Evael, NRW
18156 Registered Users
Topic Options
Rate This Topic
#474628 - 10/26/18 15:54 [SUB]float16 to var
txesmi Online
Serious User

Registered: 06/13/07
Posts: 1201
Loc: Hiporope and its pain
Hi,
I recently needed to retrieve a pixel from a 16 bits floating point formatted render target.

Code:
var var_from_float16short(short _s) {
	int _sign = _s & 32768;
	int _exp = ((int)(_s & 31744) >> 10) - 15;
	int _frac = _s & 1023;
	var _r;
	memcpy(&_r, &_frac, 4);
	_r += 1;
	if(_exp)
		_r *= pow(2, _exp);
	if (_sign)
		_r = -_r;
	return _r;
}



Salud!

Top
#475469 - 12/12/18 13:28 Re: [SUB]float16 to var [Re: txesmi]
Superku Offline
Senior Expert

Registered: 09/13/03
Posts: 6795
Loc: Kiel (Germany)
Thanks for sharing!
_________________________
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Superku The Game

Severely outdated footage: http://store.steampowered.com/app/407570

Top


Moderator:  HeelX, Lukas, Rei_Ayanami, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de