Add first version of CMath
This commit is contained in:
commit
d1eac01605
|
@ -0,0 +1,8 @@
|
||||||
|
.DS_Store
|
||||||
|
/.build
|
||||||
|
/Packages
|
||||||
|
xcuserdata/
|
||||||
|
DerivedData/
|
||||||
|
.swiftpm
|
||||||
|
.netrc
|
||||||
|
/assets/
|
|
@ -0,0 +1,294 @@
|
||||||
|
// !$*UTF8*$!
|
||||||
|
{
|
||||||
|
archiveVersion = 1;
|
||||||
|
classes = {
|
||||||
|
};
|
||||||
|
objectVersion = 77;
|
||||||
|
objects = {
|
||||||
|
|
||||||
|
/* Begin PBXFileReference section */
|
||||||
|
3BC92B322D96910000B4457A /* libCMath.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libCMath.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
3BC92B3A2D96913900B4457A /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||||
|
3BC92B3C2D96915600B4457A /* add_nums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = add_nums.h; sourceTree = "<group>"; };
|
||||||
|
3BC92B3D2D9691B300B4457A /* sub_nums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sub_nums.h; sourceTree = "<group>"; };
|
||||||
|
3BC92B3E2D9691D000B4457A /* mul_nums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mul_nums.h; sourceTree = "<group>"; };
|
||||||
|
3BC92B3F2D9691EE00B4457A /* div_nums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = div_nums.h; sourceTree = "<group>"; };
|
||||||
|
3BC92B402D9691FF00B4457A /* spc_nums.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = spc_nums.h; sourceTree = "<group>"; };
|
||||||
|
3BC92B412D96923B00B4457A /* cmath.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = cmath.c; sourceTree = "<group>"; };
|
||||||
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
3BC92B302D96910000B4457A /* Frameworks */ = {
|
||||||
|
isa = PBXFrameworksBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXGroup section */
|
||||||
|
3BC92B292D96910000B4457A = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3BC92B412D96923B00B4457A /* cmath.c */,
|
||||||
|
3BC92B3C2D96915600B4457A /* add_nums.h */,
|
||||||
|
3BC92B3D2D9691B300B4457A /* sub_nums.h */,
|
||||||
|
3BC92B3E2D9691D000B4457A /* mul_nums.h */,
|
||||||
|
3BC92B3F2D9691EE00B4457A /* div_nums.h */,
|
||||||
|
3BC92B402D9691FF00B4457A /* spc_nums.h */,
|
||||||
|
3BC92B3A2D96913900B4457A /* README.md */,
|
||||||
|
3BC92B332D96910000B4457A /* Products */,
|
||||||
|
);
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
3BC92B332D96910000B4457A /* Products */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
3BC92B322D96910000B4457A /* libCMath.dylib */,
|
||||||
|
);
|
||||||
|
name = Products;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
/* End PBXGroup section */
|
||||||
|
|
||||||
|
/* Begin PBXHeadersBuildPhase section */
|
||||||
|
3BC92B2E2D96910000B4457A /* Headers */ = {
|
||||||
|
isa = PBXHeadersBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXHeadersBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin PBXNativeTarget section */
|
||||||
|
3BC92B312D96910000B4457A /* CMath */ = {
|
||||||
|
isa = PBXNativeTarget;
|
||||||
|
buildConfigurationList = 3BC92B362D96910000B4457A /* Build configuration list for PBXNativeTarget "CMath" */;
|
||||||
|
buildPhases = (
|
||||||
|
3BC92B2E2D96910000B4457A /* Headers */,
|
||||||
|
3BC92B2F2D96910000B4457A /* Sources */,
|
||||||
|
3BC92B302D96910000B4457A /* Frameworks */,
|
||||||
|
);
|
||||||
|
buildRules = (
|
||||||
|
);
|
||||||
|
dependencies = (
|
||||||
|
);
|
||||||
|
name = CMath;
|
||||||
|
packageProductDependencies = (
|
||||||
|
);
|
||||||
|
productName = CMath;
|
||||||
|
productReference = 3BC92B322D96910000B4457A /* libCMath.dylib */;
|
||||||
|
productType = "com.apple.product-type.library.dynamic";
|
||||||
|
};
|
||||||
|
/* End PBXNativeTarget section */
|
||||||
|
|
||||||
|
/* Begin PBXProject section */
|
||||||
|
3BC92B2A2D96910000B4457A /* Project object */ = {
|
||||||
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
BuildIndependentTargetsInParallel = 1;
|
||||||
|
LastUpgradeCheck = 1620;
|
||||||
|
TargetAttributes = {
|
||||||
|
3BC92B312D96910000B4457A = {
|
||||||
|
CreatedOnToolsVersion = 16.2;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
buildConfigurationList = 3BC92B2D2D96910000B4457A /* Build configuration list for PBXProject "CMath" */;
|
||||||
|
developmentRegion = en;
|
||||||
|
hasScannedForEncodings = 0;
|
||||||
|
knownRegions = (
|
||||||
|
en,
|
||||||
|
Base,
|
||||||
|
);
|
||||||
|
mainGroup = 3BC92B292D96910000B4457A;
|
||||||
|
minimizedProjectReferenceProxies = 1;
|
||||||
|
preferredProjectObjectVersion = 77;
|
||||||
|
productRefGroup = 3BC92B332D96910000B4457A /* Products */;
|
||||||
|
projectDirPath = "";
|
||||||
|
projectRoot = "";
|
||||||
|
targets = (
|
||||||
|
3BC92B312D96910000B4457A /* CMath */,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
/* End PBXProject section */
|
||||||
|
|
||||||
|
/* Begin PBXSourcesBuildPhase section */
|
||||||
|
3BC92B2F2D96910000B4457A /* Sources */ = {
|
||||||
|
isa = PBXSourcesBuildPhase;
|
||||||
|
buildActionMask = 2147483647;
|
||||||
|
files = (
|
||||||
|
);
|
||||||
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
};
|
||||||
|
/* End PBXSourcesBuildPhase section */
|
||||||
|
|
||||||
|
/* Begin XCBuildConfiguration section */
|
||||||
|
3BC92B342D96910000B4457A /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_TESTABILITY = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
|
"$(inherited)",
|
||||||
|
);
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
3BC92B352D96910000B4457A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||||
|
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||||
|
CLANG_ANALYZER_NONNULL = YES;
|
||||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||||
|
CLANG_ENABLE_MODULES = YES;
|
||||||
|
CLANG_ENABLE_OBJC_ARC = YES;
|
||||||
|
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
|
||||||
|
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_COMMA = YES;
|
||||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
|
||||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||||
|
CLANG_WARN_EMPTY_BODY = YES;
|
||||||
|
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||||
|
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||||
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
|
||||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
|
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
|
||||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES;
|
||||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
|
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
COPY_PHASE_STRIP = NO;
|
||||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
|
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||||
|
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||||
|
GCC_NO_COMMON_BLOCKS = YES;
|
||||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
|
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||||
|
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = 15.2;
|
||||||
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
|
MTL_FAST_MATH = YES;
|
||||||
|
SDKROOT = macosx;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
3BC92B372D96910000B4457A /* Debug */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 969RMX9Y5Q;
|
||||||
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
EXECUTABLE_PREFIX = lib;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Debug;
|
||||||
|
};
|
||||||
|
3BC92B382D96910000B4457A /* Release */ = {
|
||||||
|
isa = XCBuildConfiguration;
|
||||||
|
buildSettings = {
|
||||||
|
CODE_SIGN_STYLE = Automatic;
|
||||||
|
DEVELOPMENT_TEAM = 969RMX9Y5Q;
|
||||||
|
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||||
|
DYLIB_CURRENT_VERSION = 1;
|
||||||
|
EXECUTABLE_PREFIX = lib;
|
||||||
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
|
SKIP_INSTALL = YES;
|
||||||
|
};
|
||||||
|
name = Release;
|
||||||
|
};
|
||||||
|
/* End XCBuildConfiguration section */
|
||||||
|
|
||||||
|
/* Begin XCConfigurationList section */
|
||||||
|
3BC92B2D2D96910000B4457A /* Build configuration list for PBXProject "CMath" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
3BC92B342D96910000B4457A /* Debug */,
|
||||||
|
3BC92B352D96910000B4457A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
3BC92B362D96910000B4457A /* Build configuration list for PBXNativeTarget "CMath" */ = {
|
||||||
|
isa = XCConfigurationList;
|
||||||
|
buildConfigurations = (
|
||||||
|
3BC92B372D96910000B4457A /* Debug */,
|
||||||
|
3BC92B382D96910000B4457A /* Release */,
|
||||||
|
);
|
||||||
|
defaultConfigurationIsVisible = 0;
|
||||||
|
defaultConfigurationName = Release;
|
||||||
|
};
|
||||||
|
/* End XCConfigurationList section */
|
||||||
|
};
|
||||||
|
rootObject = 3BC92B2A2D96910000B4457A /* Project object */;
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Workspace
|
||||||
|
version = "1.0">
|
||||||
|
<FileRef
|
||||||
|
location = "self:">
|
||||||
|
</FileRef>
|
||||||
|
</Workspace>
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Bachelorproef Proof-of-Concept 3 | CMath
|
||||||
|
Deze directory bevat de C-library die gebruikt wordt om de 3e Proof-of-Concept (Swift <> C interoperability) mogelijk te maken.
|
||||||
|
|
||||||
|
Concreet is dit een simpele library die basis wiskunde bewerkingen kan uitvoeren, vergelijkbaar met wat men zou verwachten bij een basis calculator.
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// add_nums.h
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __ADD_NUMS_H
|
||||||
|
#define __ADD_NUMS_H
|
||||||
|
|
||||||
|
double add_nums(double a, double b);
|
||||||
|
|
||||||
|
#endif // __ADD_NUMS_H
|
|
@ -0,0 +1,75 @@
|
||||||
|
//
|
||||||
|
// cmath.c
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "add_nums.h"
|
||||||
|
#include "sub_nums.h"
|
||||||
|
#include "mul_nums.h"
|
||||||
|
#include "div_nums.h"
|
||||||
|
#include "spc_nums.h"
|
||||||
|
|
||||||
|
double add_nums(double a, double b) {
|
||||||
|
return a + b;
|
||||||
|
}
|
||||||
|
|
||||||
|
double sub_nums(double a, double b) {
|
||||||
|
return b - a;
|
||||||
|
}
|
||||||
|
|
||||||
|
double mul_nums(double a, double b) {
|
||||||
|
return a * b;
|
||||||
|
}
|
||||||
|
|
||||||
|
double div_nums(double a, double b) {
|
||||||
|
if (a == 0) return 0; // Cannot divide by 0
|
||||||
|
|
||||||
|
return b / a;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uses "poor man's pow" to determine the power of a fractional exponent.
|
||||||
|
double pow(double x, double exp) {
|
||||||
|
if (x == 0) return 0;
|
||||||
|
if (exp == 0) return 1;
|
||||||
|
if (exp < 0) return 1 / pow(x, -exp);
|
||||||
|
|
||||||
|
int full_part = (int) exp;
|
||||||
|
double frac_part = exp - full_part;
|
||||||
|
double result = 1.0;
|
||||||
|
|
||||||
|
// int pow
|
||||||
|
for (size_t i = 0; i < full_part; i++) {
|
||||||
|
result *= x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Approximate fraction
|
||||||
|
if (frac_part != 0) {
|
||||||
|
double temp = 1.0;
|
||||||
|
double term = 1.0;
|
||||||
|
|
||||||
|
for (size_t i = 1; i < POOR_MANS_POW_GUESSES; i++) {
|
||||||
|
term *= (frac_part * (x - 1)) / i;
|
||||||
|
temp += term;
|
||||||
|
}
|
||||||
|
|
||||||
|
result *= temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uses Newton's Square Root to get a decent guess of the sqrt.
|
||||||
|
double sqrt(double x) {
|
||||||
|
if (x <= 0) return 0; // Negative roots are way out of scope for this thesis.
|
||||||
|
|
||||||
|
double guess = x / 2.0;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < NEWTONIAN_DIV_GUESSES; i++) {
|
||||||
|
guess = (guess + x / guess) / 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return guess;
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// div_nums.h
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __DIV_NUMS_H
|
||||||
|
#define __DIV_NUMS_H
|
||||||
|
|
||||||
|
double div_nums(double a, double b);
|
||||||
|
|
||||||
|
#endif // __DIV_NUMS_H
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// mul_nums.h
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __MUL_NUMS_H
|
||||||
|
#define __MUL_NUMS_H
|
||||||
|
|
||||||
|
double mul_nums(double a, double b);
|
||||||
|
|
||||||
|
#endif // __MUL_NUMS_H
|
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// spc_nums.h
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __SPC_NUMS_H
|
||||||
|
#define __SPC_NUMS_H
|
||||||
|
|
||||||
|
#define POOR_MANS_POW_GUESSES 12
|
||||||
|
#define NEWTONIAN_DIV_GUESSES 12
|
||||||
|
|
||||||
|
double pow(double x, double exp);
|
||||||
|
double sqrt(double x);
|
||||||
|
|
||||||
|
#endif // __SPC_NUMS_H
|
|
@ -0,0 +1,13 @@
|
||||||
|
//
|
||||||
|
// sub_nums.h
|
||||||
|
// CMath
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 28/03/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __SUB_NUMS_H
|
||||||
|
#define __SUB_NUMS_H
|
||||||
|
|
||||||
|
double sub_nums(double a, double b);
|
||||||
|
|
||||||
|
#endif // __SUB_NUMS_H
|
|
@ -0,0 +1,17 @@
|
||||||
|
//
|
||||||
|
// CMath-Bridging-Header.h
|
||||||
|
// Interop-BridgingHeader
|
||||||
|
//
|
||||||
|
// Created by TheAlgorithm476 on 09/04/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __CMATH_BRIDGING_HEADER
|
||||||
|
#define __CMATH_BRIDGING_HEADER
|
||||||
|
|
||||||
|
#include "add_nums.h"
|
||||||
|
#include "sub_nums.h"
|
||||||
|
#include "mul_nums.h"
|
||||||
|
#include "div_nums.h"
|
||||||
|
#include "spc_nums.h"
|
||||||
|
|
||||||
|
#endif // __CMATH_BRIDGING_HEADER
|
|
@ -0,0 +1,4 @@
|
||||||
|
// The Swift Programming Language
|
||||||
|
// https://docs.swift.org/swift-book
|
||||||
|
|
||||||
|
print("Hello, world!")
|
Loading…
Reference in New Issue