ObjFW  Check-in [69931b1982]

Overview
Comment:OFColor: Use roundf instead of nearbyintf

This fixes DJGPP which doesn't have nearbyintf.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 69931b1982b57295231c71599f77bf8905b8dbed39a764bda35e96dc7888162d
User & Date: js on 2024-03-27 23:33:31
Other Links: manifest | tags
Context
2024-03-27
23:45
OFStdIOStream: Implement cursor movement on MS-DOS check-in: 943e9c0956 user: js tags: trunk
23:33
OFColor: Use roundf instead of nearbyintf check-in: 69931b1982 user: js tags: trunk
2024-03-23
16:43
OFMessagePackTests: Add more tests check-in: 66f22a2831 user: js tags: trunk
Changes

Modified src/OFColor.m from [9779b523cd] to [eb180f1d4b].

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@implementation OFPlaceholderColor
- (instancetype)initWithRed: (float)red
		      green: (float)green
		       blue: (float)blue
		      alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
	uint8_t redInt = nearbyintf(red * 255);
	uint8_t greenInt = nearbyintf(green * 255);
	uint8_t blueInt = nearbyintf(blue * 255);

	if (fabsf(red * 255 - redInt) < allowedImprecision &&
	    fabsf(green * 255 - greenInt) < allowedImprecision &&
	    fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) {
		id ret = [OFTaggedPointerColor colorWithRed: redInt
						      green: greenInt
						       blue: blueInt];







|
|
|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@implementation OFPlaceholderColor
- (instancetype)initWithRed: (float)red
		      green: (float)green
		       blue: (float)blue
		      alpha: (float)alpha
{
#ifdef OF_OBJFW_RUNTIME
	uint8_t redInt = roundf(red * 255);
	uint8_t greenInt = roundf(green * 255);
	uint8_t blueInt = roundf(blue * 255);

	if (fabsf(red * 255 - redInt) < allowedImprecision &&
	    fabsf(green * 255 - greenInt) < allowedImprecision &&
	    fabsf(blue * 255 - blueInt) < allowedImprecision && alpha == 1) {
		id ret = [OFTaggedPointerColor colorWithRed: redInt
						      green: greenInt
						       blue: blueInt];