English: Aliasing a positive IEEE-754floating point number x to an integer Ix (like in C: float x = ...; int32_t i = * (int32_t *) &x;) yields a scaled and shifted approximation of its base-2 logarithm. This is the basis of the fast inverse square root algorithm.
Français : Si un nombre positif x représenté en virgule flottante au format IEEE 754 est interprété comme un entier Ix (comme en C : float x = ...; int32_t i = * (int32_t *) &x;) cela produit, à une transformation linéaire près, une approximation de son logarithme en base 2. Cette approximation est le fondement de l'algorithme de racine carrée inverse rapide.
Warning: This source contains non-ASCII characters in label 3, in the title of the first curve and in comments.
#!/usr/bin/gnuplot# Aliasing a float32 to an int32 yields an approximation of its base-2# logarithm.# Parameters for IEEE-754 single-precision floatsL=2**23# mantissa scaling factorB=127# exponent bias# For m ∈ [0, 1), log₂(1 + m) ≈ 1 + σsigma=0.0430357# Assume x is a positive normal float32.# Compute I(x): the int32 aliased to x.log_of_2=log(2)log2(x)=log(x)/log_of_2round(x)=floor(x+0.5)e(x)=floor(log2(x))# exponentm(x, e_x)=x/2**e_x-1# mantissa, without the leading 1M(x, e_x)=round(m(x,e_x)*L)# scaled and rounded mantissaI2(x, e_x)=(e_x+B)*L+M(x,e_x)I(x)=I2(x,e(x))# Best fit to a logarithmscaled_log(x)=L*log2(x)+L*(B-sigma)# Do the plotsetterminalsvgsize640,480enhancedsetoutput'Log_by_aliasing_to_int.svg'setxrange[0:10]setyrange[0x3d800000:]setformaty"0x%x"setyticsLsetkeytopleftLeftreverseinvertspacing1.4setsamples200setstyleline1lw3lcrgb"gray80"setstyleline2lw1lcrgb"blue"setstyleincrementusersetlabel1"L = 2^{23}"at6,0x3fc00000setlabel2"B = 127"at6,0x3f600000setlabel3"σ = 0.0430357"at6,0x3f000000plotscaled_log(x)title"L log_2(x) + L (B − σ)",\
I(x)title'I_x'lt3
লাইসেন্স প্রদান
আমি, এই কাজের স্বত্বাধিকারী, এতদ্দ্বারা আমি এই কাজকে নিম্ন বর্ণিত লাইসেন্সের আওতায় প্রকাশ করলাম:
বণ্টন করতে পারেন – এ কাজটি অনুলিপি, বিতরণ এবং প্রেরণ করতে পারেন
পুনঃমিশ্রণ করতে পারেন – কাজটি অভিযোজন করতে পারেন
নিম্নের শর্তাবলীর ভিত্তিতে:
স্বীকৃতিপ্রদান – আপনাকে অবশ্যই যথাযথ স্বীকৃতি প্রদান করতে হবে, লাইসেন্সের একটি লিঙ্ক সরবরাহ করতে হবে এবং কোনো পরিবর্তন হয়েছে কিনা তা নির্দেশ করতে হবে। আপনি যেকোনো যুক্তিসঙ্গত পদ্ধতিতে এটি করতে পারেন। কিন্তু এমন ভাবে নয়, যাতে প্রকাশ পায় যে লাইসেন্সধারী আপনাকে বা আপনার এই ব্যবহারের জন্য অনুমোদন দিয়েছে।
একইভাবে বণ্টন – আপনি যদি কাজটি পুনঃমিশ্রণ, রুপান্তর, বা এর ওপর ভিত্তি করে নতুন সৃষ্টিকর্ম তৈরি করেন, তবে আপনাকে অবশ্যই আপনার অবদান একই লাইসেন্স বা একই রকমের লাইসেন্সের আওতায় বিতরণ করতে হবে।
এই ফাইলে অতিরিক্ত কিছু তথ্য আছে। সম্ভবত যে ডিজিটাল ক্যামেরা বা স্ক্যানারের মাধ্যমে এটি তৈরি বা ডিজিটায়িত করা হয়েছিল, সেটি কর্তৃক তথ্যগুলি যুক্ত হয়েছে। যদি ফাইলটি তার আদি অবস্থা থেকে পরিবর্তিত হয়ে থাকে, কিছু কিছু বিবরণ পরিবর্তিত ফাইলটির জন্য প্রযোজ্য না-ও হতে পারে।