{"id":18952497,"url":"https://github.com/simonwhitaker/swmath","last_synced_at":"2026-03-29T03:30:20.059Z","repository":{"id":15037231,"uuid":"17763133","full_name":"simonwhitaker/swmath","owner":"simonwhitaker","description":"CGFloat-friendly math functions","archived":false,"fork":false,"pushed_at":"2014-03-14T23:43:10.000Z","size":140,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-01-01T02:29:06.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonwhitaker.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-14T23:00:31.000Z","updated_at":"2014-03-14T23:43:08.000Z","dependencies_parsed_at":"2022-09-07T13:41:54.847Z","dependency_job_id":null,"html_url":"https://github.com/simonwhitaker/swmath","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwhitaker%2Fswmath","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwhitaker%2Fswmath/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwhitaker%2Fswmath/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonwhitaker%2Fswmath/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonwhitaker","download_url":"https://codeload.github.com/simonwhitaker/swmath/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239951721,"owners_count":19723915,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T13:33:41.036Z","updated_at":"2026-03-29T03:30:19.996Z","avatar_url":"https://github.com/simonwhitaker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swmath: CGFloat-friendly math functions\n\nCalling `math.h` functions like `floor` and `floorf` on CGFloat variables becomes problematic when compiling the same code for both 32-bit and  64-bit platforms, since CGFloat is double on 64-bit, float on 32-bit.  Hence, if you compile with -Wconversion set, `floorf` will give a warning  on 64-bit, while `floor` gives a warning on 32-bit.\n\n**swmath** offers a set of architecture-independent math functions, written using plain old function overloading which is enabled using the `__attribute__((overloadable))` Clang language extension.\n\n## Status\n\nRight now this is a very early, mostly untested hack. Feel free to play with it, test it out and see how you get on. \n\n## What about `tgmath.h`?\n\nI know of `tgmath.h`, but I really liked the idea of using Clang's function overloading instead. If you're happy with `tgmath.h` then by all means stick with it.\n\n## Contributing\n\nPull requests are very, very welcome. Please note however that `swmath.h` and `swmath.c` are automatically generated; please don't submit changes to those files, since the changes won't persist.\n\nAll the magic happens in `scripts/swmath-gen.py`, so that's where you should make improvements. If you don't know Python feel free to open an issue instead, explaining the changes you'd like to see in the C code.\n\n## Known issues\n\n* No unit tests\n* No support for `nan`, `nanf` and `nanl` since those three functions share the same signature and hence can't be overridden this way.\n\n## Refs\n \n* http://clang.llvm.org/docs/AttributeReference.html#overloadable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonwhitaker%2Fswmath","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonwhitaker%2Fswmath","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonwhitaker%2Fswmath/lists"}