简体   繁体   English

“modf()”(来自 C/C++ 等的数学 function 等)的简写是什么?

[英]what is “modf()” (a math function from C/C++ etc.) shorthand for?

In C and C++, the modf function can break floating number into fractional and integral parts.在 C 和 C++ 中, modf function 可以将浮点数分解为小数和整数部分。

I'm curious about what does "modf" stand for.我很好奇“modf”代表什么。 What is it shorthand for?它是什么的简写?

From the Linux man pages :Linux 手册页

Name modf, modff, modfl - extract signed integral and fractional values from floating-point number名称 modf、modff、modfl - 从浮点数中提取有符号整数和小数

Meaning that modf stands for mod ulus and f raction, as also @chux - Reinstate Monica suggested.这意味着modf代表数和分数,正如@chux - Reinstate Monica 所建议的那样。

We can also read in the same page,我们也可以在同一页阅读,

Synopsis概要

#include <math.h>

double modf(double x, double *iptr);
float modff(float x, float, *iptr);
long double modfl(long double x, long double *iptr);

This makes clear that the f does not stand for float , but for fraction.这清楚地表明 f 不代表float ,而是代表分数。 This is for C , where modf() works on double s, modff() on float s and modfl() on long double s.这是针对C的,其中modf()适用于double s, modff()适用于float s, modfl()long double s。

what is modf() shorthand for? modf()的简写是什么?

The function breaks a floating point number up into whole number and fractional parts. function 将浮点数分解为整数和小数部分。

Looking at the 1989 definition (I do not find it in K & R 1st Ed.)...查看 1989 年的定义(我在 K & R 第一版中找不到它。)...

The modf function break the argument value into integral and fractional parts, each of which has the same sign as the argument. modf function 将参数value分解为整数和小数部分,每个部分与参数的符号相同。 It stores the integral part as a double in the object pointed to by iptr .它将整数部分作为double精度部分存储在iptr指向的 object 中。 The modf function returns the signed fractional part of value . modf function 返回value的有符号小数部分。 C89 7.5.4.6 C89 7.5.4.6

... has lead me to think of "mod" as the "left over" part which cannot be expressed with an integer and "f" as fraction to describe the returning value. ...使我将“mod”视为“剩余”部分,不能用 integer 和“f”作为描述返回值的分数来表示。 Could not call it fmod() as that is used for a % like function for double , nor plain mod() which is too integer like.不能将其称为fmod() ,因为它用于像double之类的% ,也不能称为普通mod() ,后者太像 integer 。

Sorry this in only based on my understanding since the late '80s.抱歉,仅基于我自 80 年代后期以来的理解。 Perhaps an 1960s/70s reference or guru can be found.也许可以找到 1960 年代/70 年代的参考资料或大师。

I suspect "mod" as the fractional remainder comes from Fortran of the 1970s, yet my reference books are chest deep in the maze .我怀疑“mod”作为小数余数来自 1970 年代的 Fortran,但我的参考书在迷宫深处

After doing some research I stumbled upon the Mod and remainder are not the same that states that mod and remainder are different things, when both numbers have the same sign, mod and remainder are the same, but when one of the signs is different the programming language implementation can have different results as shown on this table .在做了一些研究之后,我偶然发现Mod 和余数不相同,说明 mod 和余数是不同的东西,当两个数字具有相同的符号时,mod 和余数是相同的,但是当其中一个符号不同时,编程语言实现可以有不同的结果,如下所示。 In C fmod( A, B ) returns the remainder of A and B , the difference with the % operator is that it works on floating point numbers, meaning that A and B or any is a floating point number ( double , float or long double ).C fmod( A, B )返回A and Bremainder ,与%运算符的区别在于它适用于浮点数,这意味着A and B or any是浮点数( doublefloatlong double )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C ++中'和','或'等关键字的目的是什么? - What is the purpose of the 'and', 'or', etc. keywords in C++? C++ 函数`modf` 在内部是如何工作的? - How does the C++ function `modf` work internally? C++:关键字类 A 有什么作用? B级; class C;等文件开头完成? - C++: What does having keyword class A; class B; class C;, etc. at the beginning of a file accomplish? 是否可以从c#(或c ++)中获取HTML元素(例如iFrame,div等)的窗口句柄? - Is it possible to get a window handle of an HTML element, such as iFrame, div, etc. from c# (or c++)? 为什么 C++ 预增量加法与 javascript、C# 等有独特的不同? (序列点?) - Why is C++ preincrement addition uniquely different from javascript, C#, etc.? (Sequence points?) Scala等与C / C ++ / Fortran之间的性能比较? - Comparison of performance between Scala etc. and C/C++/Fortran? 为什么在C / C ++中使用uint_8等? - Why is uint_8 etc. used in C/C++? 什么是具有最简单学习曲线的C ++ GUI构建选项 - VS / Qt / wxWidgets /等? - What's the C++ GUI building option with the easiest learning curve - VS/Qt/wxWidgets/etc.? 在C ++中,哪些类别(左值,右值,右值等)可以生成类类型临时的表达式? - In C++, what categories (lvalue, rvalue, xvalue, etc.) can expressions that produce temporaries of class type fall into? 继承Java集合接口(Set,Map,List等)的C ++等价物是什么? 或者扩展AbstractCollection? - What is the C++ equivalent of inheriting a Java collection interface (Set, Map, List etc.)? Or extending AbstractCollection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM