Dynamic Variable Naming and Reference (ColdFusion)

One Option: Setting a dynamic variable name: <cfset variables[“GC” & AID] = “Testing” /> Output the value of the dynamic variable name: <cfoutput>#variables[“GC” & AID]#</cfoutput> Another Option: Setting a dynamic variable name: <cfset variables[“GC#AID#”] = “Testing” /> Output the value of the dynamic variable name: <cfoutput>#variables[“GC#AID#”]#</cfoutput>

Comparing IEEE floats and doubles for equality

The best approach I think is to compare ULPs. bool is_nan(float f) { return (*reinterpret_cast<unsigned __int32*>(&f) & 0x7f800000) == 0x7f800000 && (*reinterpret_cast<unsigned __int32*>(&f) & 0x007fffff) != 0; } bool is_finite(float f) { return (*reinterpret_cast<unsigned __int32*>(&f) & 0x7f800000) != 0x7f800000; } // if this symbol is defined, NaNs are never equal to anything (as is normal … Read more

In MATLAB, are variables REALLY double-precision by default?

They’re doubles. vpa() is simply choosing to display non-significant digits beyond the floating point relative accuracy, where printf() and disp() truncate or zero them out. You’re only getting your original four digits back out because the literal you chose to initialize num with just happens to be the exact decimal expansion of a binary double … Read more

Why there are two ways of declaring variables in Go, what’s the difference and which to use?

The Variable declarations make it clear that variables are declared. The var keyword is required, it is short and expresses what is done (at the file level everything excluding comments has to start with a keyword, e.g. package, import, const, type, var, func). Like any other block, variable declarations can be grouped like this: var … Read more