Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. ncode:
  2.  
  3. depth in [0,1]
  4. depth *= 1 - 1 / (256 * 256 * 256 * 256)
  5. depth in [0,1[
  6.  
  7. exp = 0
  8. while(depth < 1){
  9. depth *= 2;
  10. exp += 1;
  11. }
  12.  
  13.  
  14.  
  15. depth *= 256.0
  16. depth0 = floor(depth)
  17. depth = frac(depth)
  18.  
  19. depth *= 256.0
  20. depth1 = floor(depth)
  21. depth = frac(depth)
  22.  
  23. depth *= 256.0
  24. depth2 = floor(depth)
  25. depth = frac(depth)
  26.  
  27. output : [depth0 / 255.0, depth1 / 255.0, depth2 / 255.0]
  28.  
  29.  
  30. ###############
  31. decode:
  32. [depth0, depth1, depth2, exp]
  33.  
  34. depth = depth0 * 255.0 / 256.0 + depth1 * 255.0 / (256.0 * 256.0) + depth2 * 255.0 / (256.0 * 256.0 * 256.0)
  35.  
  36. while exp != 0 {
  37. depth = depth / 2;
  38. exp -= 1;
  39. }
  40.  
  41.  
  42.  
  43. 16M [0,1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement